Fields

Re-declares all DRF fields such that they also inherit DynamicForms’ mixins.

To use, import like so:

from dynamicforms.fields import {your desired field classes}

Make sure you don’t import DRF’s field classes over these.

Class reference

class BooleanField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class CharField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ChoiceField(choices, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class DateField(format=<class 'rest_framework.fields.empty'>, input_formats=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class DateTimeField(format=<class 'rest_framework.fields.empty'>, input_formats=None, default_timezone=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class DecimalField(max_digits, decimal_places, coerce_to_string=None, max_value=None, min_value=None, localize=False, rounding=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class DictField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class DurationField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class EmailField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class FileField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class FilePathField(path, match=None, recursive=False, allow_files=True, allow_folders=False, required=None, read_only=False, write_only=False, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class FloatField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class HStoreField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class HiddenField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class HyperlinkedIdentityField(view_name=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, url_reverse: Optional[str] = None, placeholder: Optional[str] = None, additional_parameters: Optional[dict] = None, query_field: str = 'query', actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class HyperlinkedRelatedField(view_name=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, url_reverse: Optional[str] = None, placeholder: Optional[str] = None, additional_parameters: Optional[dict] = None, query_field: str = 'query', actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class IPAddressField(protocol='both', read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ImageField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class IntegerField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class JSONField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ListField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ManyRelatedField(child_relation=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=True, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ModelField(model_field, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class MultipleChoiceField(choices, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class NullBooleanField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class PrimaryKeyRelatedField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, url_reverse: Optional[str] = None, placeholder: Optional[str] = None, additional_parameters: Optional[dict] = None, query_field: str = 'query', actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class ReadOnlyField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class RegexField(regex, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class SerializerMethodField(method_name=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class SlugField(allow_unicode=False, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class SlugRelatedField(slug_field=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, url_reverse: Optional[str] = None, placeholder: Optional[str] = None, additional_parameters: Optional[dict] = None, query_field: str = 'query', actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class StringRelatedField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, url_reverse: Optional[str] = None, placeholder: Optional[str] = None, additional_parameters: Optional[dict] = None, query_field: str = 'query', actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class TimeField(format=<class 'rest_framework.fields.empty'>, input_formats=None, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class URLField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]
class UUIDField(read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False, actions: dynamicforms.action.Actions = None, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kw)[source]

Field mixins

class ActionMixin(*args, actions: dynamicforms.action.Actions = None, **kwargs)[source]

Used in fields allowing declaration of actions that happen when field values change

class DateFieldMixin(*args, table_format: str = '', **kwargs)[source]
class DateTimeFieldMixin(*args, table_format: str = '', **kwargs)[source]
class DisplayMode[source]

An enumeration.

class HiddenFieldMixin(*args, **kwargs)[source]
class NaturalDateTimeMixin(*args, table_format: str = '', **kwargs)[source]

Used for rendering datetime in human natural style (e.g.: 1 hour, 10 minutes ago)

class NullChoiceMixin[source]
Declaring ChoiceField’s null_choice_text
(what should be rendered for “no selection”; DRF’s default is ———) We also support user declaring a choice with None value and a different text (see hidden fields example)
class RenderMixin(*args, uuid: uuid.UUID = None, display: dynamicforms.mixins.DisplayMode = None, display_table: dynamicforms.mixins.DisplayMode = None, display_form: dynamicforms.mixins.DisplayMode = None, table_classes: str = '', **kwargs)[source]

Is used in fields and serializers, so every field and serializer gets its unique id. Also to specify where and how fields should render.

In form where serializer is used, id is serializers uuid. Table with list of records has id »list-serializer.uuid«, in dialog id is »dialog-{serializer.uuid}« and save button’s id on dialog is »save-{serializer.uuid}«

Similar for fields: All inputs in HTML get id from field.uuid. Div that contains all that belongs to the field has »container-{field.uuid}« for id, label has »label-{field.uuid}« and help text (if exists) has »help-{field.uuid}« for id.

Used for rendering individual field to table view

render_to_table(value, row_data)[source]

Renders field value for table view

Parameters:
  • value – field value
  • row_data – data for entire row (for more complex renderers)
Returns:

rendered value for table view

class TimeFieldMixin(*args, table_format: str = '', **kwargs)[source]