Skip to content

Fields and types

classes.decore_fields

BackrefMetaField

Bases: MetaField

The BackrefMetaField is required so that decore Front can display relationships between models. It can be assigned to the filter or a form, for example. It is a MetaField and is not assigned a column in the database.

Parameters:

Name Type Description Default
verbose_name str

A user-readable name for the field.

None
help_text str

Zusätzlicher Text, der in decore Front angezeigt wird.

None
filter_fields list

Eine Liste vom Typ String. Es werden nur die angegebenen Felder im Filter angezeigt. Wenn empty, werden alle Felder angezeigt.

[]
choice_query dict

Ein dictonary, das eine Abfrage enthält, die beim laden von Optionen (z.B. in Auswahlfeldern im Frontend) berücksichtigt wird. Die Abfrage muss sich auf das Referenzmodell beziehen.

{}

Warning

The name of the BackRefMetaField must match the value of the specified backref parameter in the ForeignKey or ManyToMany field in the reference model. In the following example, the name of the BackRefMetaField is equal to accounts and so is the value of the ForeignKey backref parameter.

class User(Conform_model):
    username = CharField(verbose_name='Username')
    accounts = BackRefMetaField(null=True, verbose_name='Accounts', choice_query={'domain__eq': 'example.com'}
class Account(Conform_model):
    user = ForeignKeyField(User, backref='accounts', null=True, verbose_name='User')
    prefix = CharField(verbose_name='Mail prefix')
    domain = CharField(verbose_name='Mail domain', default='example.com')

BooleanField

Bases: BooleanField

A field to store boolean values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

CharField

Bases: CharField

A field to store char values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool unique: If True, the field must be unique in database table. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

DateField

Bases: DateField

A field to store date values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

DateTimeField

Bases: DateTimeField

A field to store datetime values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

FloatField

Bases: FloatField

A field to store float values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

PasswordField

Bases: Field

:warning The keybase is a KeePass file and should be protected by setting the correct access rights (ACL).

A field to store passwords in the keybase and to use them again.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

.. code-block:: python

class User(Conform_model):
    password = PasswordField(null=False, verbose_name='Password')

ForeignKeyField

Bases: ForeignKeyField

A field to represent a one-to-many relationship between two models.

:param Model model: The model to which the relationship is to be established. :param str backref: The name of the field in the reference model that represents the relationship to the model. :param bool null: If True, the field is allowed to be null. Defaults to False. :param str verbose_name: A human-readable name for the field. :param str help_text: Additional text to be displayed in decore Front. :param list filter_fields: A List of type string. Only the speciefied fields will be displayed in the filter. If None, all fields will be displayed. :param dict choice_query: A dictonary containing a query to be used when querying choices (e.g. in selection fields in the frontend). The query always refers to the reference model.

IntegerField

Bases: IntegerField

A field to store integer values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.

ManyToManyField

Bases: ManyToManyField

A field to represent a many-to-many relationship between two models. It is a MetaField and does not get a column in the database. However, a through model is created by decore Base, which represents the relationship between the two models.

:param Model model: The model to which the relationship is to be established. :param str backref: The name of the field in the reference model that represents the relationship to the model. :param bool null: If True, the field is allowed to be null. Defaults to False. :param str verbose_name: A human-readable name for the field. :param str help_text: Additional text to be displayed in decore Front. :param list filter_fields: A List of type string. Only the speciefied fields will be displayed in the filter. If None, all fields will be displayed. :param dict choice_query: A dictonary containing a query to be used when querying choices (e.g. in selection fields in the frontend). The query always refers to the reference model.

.. code-block:: python

class Account(Conform_model):
    users = ManyToManyField(User, backref='accounts', null=True, verbose_name='Users')
    prefix = CharField(verbose_name='Mail prefix')
    domain = CharField(verbose_name='Mail domain', default='example.com')

.. code-block:: python

class User(Conform_model):
    username = CharField(verbose_name='Username')
    accounts = BackRefMetaField(null=True, verbose_name='Accounts', choice_query={'domain__eq': 'example.com'}

TextField

Bases: TextField

A field to store text values.

:param bool null: If True, the field is allowed to be null. Defaults to False. :param bool default: The default value for the field. Defaults to None. :param str help_text: Additional text to be displayed in decore Front. :param str verbose_name: A human-readable name for the field.