A TextField which stores its value on the model instance as a python object and stores its value in the database as JSON. Validated with json_validator().
Stores a selection of multiple items with unique slugs in the form of a comma-separated list. Also knows how to correctly handle RegistryIterators passed in as choices.
A TextField which is validated with a TemplateValidator. allow, disallow, and secure will be passed into the validator’s construction.
AttributeProxyFields can be assigned as fields on a subclass of philo.models.base.Entity. They act like any other model fields, but instead of saving their data to the model’s table, they save it to Attributes related to a model instance. Additionally, a new Attribute will be created for an instance if and only if the field’s value has been set. This is relevant i.e. for PassthroughAttributeMappers and TreeAttributeMappers, where even an Attribute with a value of None will prevent a passthrough.
Example:
class Thing(Entity):
numbers = models.PositiveIntegerField()
improvised = JSONAttribute(models.BooleanField)
Parameters: | attribute_key – The key of the attribute that will be used to store this field’s value, if it is different than the field’s name. |
---|
The remaining parameters have the same meaning as for ordinary model fields.
Returns a form field capable of accepting values for the AttributeProxyField.
Returns the value of this field in the given model instance.
Final conversion of value before it gets stored on an Entity instance. This will be called during EntityForm.save().
Raise an appropriate exception if value is not valid for this AttributeProxyField.
Returns True if a default value was provided and False otherwise.
Returns the choices passed into the constructor.
Each AttributeProxyField subclass can define a value_class to use for creation of new AttributeValues
Handles an Attribute with a JSONValue.
Parameters: | field_template – A django form field instance that will be used to guide rendering and interpret values. For example, using django.forms.BooleanField will make this field render as a checkbox. |
---|
alias of JSONValue
If the field template is a DateField or a DateTimeField, this will convert the default return value to a datetime instance.
If value is a datetime.datetime instance, this will convert it to a format which can be stored as correct JSON.
Handles an Attribute with a ForeignKeyValue.
Parameters: | limit_choices_to – A Q object, dictionary, or ContentTypeLimiter to restrict the queryset for the ForeignKeyAttribute. |
---|
alias of ForeignKeyValue
Converts the default value type (a model instance) to a pk.
Handles an Attribute with a ManyToManyValue.
Parameters: | limit_choices_to – A Q object, dictionary, or ContentTypeLimiter to restrict the queryset for the ManyToManyAttribute. |
---|
alias of ManyToManyValue
Converts the default value type (a queryset) to a list of pks.