db.models.Field.primary_key

Field.primary_key If True, this field is the primary key for the model. If you don’t specify primary_key=True for any field in your model, Django will automatically add an AutoField to hold the primary key, so you don’t need to set primary_key=True on any of your fields unless you want to override the default primary-key behavior. For more, see Automatic primary key fields. primary_key=True implies null=False and unique=True. Only one primary key is allowed on an object. The primary key fiel

db.models.Field.pre_save()

pre_save(model_instance, add) [source] Method called prior to get_db_prep_save() to prepare the value before being saved (e.g. for DateField.auto_now). model_instance is the instance this field belongs to and add is whether the instance is being saved to the database for the first time. It should return the value of the appropriate attribute from model_instance for this field. The attribute name is in self.attname (this is set up by Field). See Preprocessing values before saving for usage. F

db.models.Field.rel_db_type()

rel_db_type(connection) [source] New in Django 1.10. Returns the database column data type for fields such as ForeignKey and OneToOneField that point to the Field, taking into account the connection. See Custom database types for usage in custom fields. There are three main situations where Django needs to interact with the database backend and fields: when it queries the database (Python value -> database backend value) when it loads data from the database (database backend value ->

db.models.Field.related_model

Field.related_model Points to the model the field relates to. For example, Author in ForeignKey(Author, on_delete=models.CASCADE). If a field has a generic relation (such as a GenericForeignKey or a GenericRelation) then related_model will be None.

db.models.Field.one_to_many

Field.one_to_many Boolean flag that is True if the field has a one-to-many relation, such as a GenericRelation or the reverse of a ForeignKey; False otherwise.

db.models.Field.model

Field.model Returns the model on which the field is defined. If a field is defined on a superclass of a model, model will refer to the superclass, not the class of the instance.

db.models.Field.null

Field.null If True, Django will store empty values as NULL in the database. Default is False. Avoid using null on string-based fields such as CharField and TextField because empty string values will always be stored as empty strings, not as NULL. If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the empty string. In most cases, it’s redundant to have two possible values for “no data;” the Django convention is to use the empty string, not NU

db.models.Field.one_to_one

Field.one_to_one Boolean flag that is True if the field has a one-to-one relation, such as a OneToOneField; False otherwise.

db.models.Field.many_to_many

Field.many_to_many Boolean flag that is True if the field has a many-to-many relation; False otherwise. The only field included with Django where this is True is ManyToManyField.

db.models.Field.is_relation

Field.is_relation Boolean flag that indicates if a field contains references to one or more other models for its functionality (e.g. ForeignKey, ManyToManyField, OneToOneField, etc.).