Model Meta Options
The ModelMeta class contains metadata about the model that is not field-specific.
Usage
django/db/models/options.py:90
Available Meta Options
abstract
If True, this model will be an abstract base class.When True, the model is treated as an abstract base class and no database table is created.
django/db/models/options.py:146
app_label
Defines which app the model belongs to. Rarely needed as Django can usually determine this automatically.The name of the app that contains this model.
django/db/models/options.py:137
base_manager_name
The name of the manager to use for_base_manager.
The attribute name of the manager to use as the base manager.
django/db/models/options.py:121
db_table
The name of the database table to use for the model.The database table name. If not provided, Django constructs one from app_label and model name.
django/db/models/options.py:126
db_table_comment
A comment on the database table. Requires database support for comments.A comment to add to the database table.
django/db/models/options.py:127
db_tablespace
The database tablespace to use for this model’s table.The name of the database tablespace. Falls back to DEFAULT_TABLESPACE setting.
django/db/models/options.py:140
default_manager_name
The name of the manager to use as the default manager.The attribute name of the manager to use as the default manager.
django/db/models/options.py:122
default_permissions
Defaults to('add', 'change', 'delete', 'view'). Customize to change the permissions created automatically.
A tuple/list of permission names to create automatically.
django/db/models/options.py:134
default_related_name
The name that will be used by default for the relation from a related object back to this one.Default related_name for reverse relations. Supports %(app_label)s, %(model_name)s, and %(class)s substitution.
django/db/models/options.py:170
get_latest_by
The name of a field or list of field names to use for thelatest() and earliest() methods.
Field name(s) to order by for latest() and earliest() methods.
django/db/models/options.py:138
managed
Defaults to True. If False, no database table creation, modification, or deletion will be performed for this model.If False, Django will not create or modify database tables for this model.
django/db/models/options.py:147
order_with_respect_to
Makes this object orderable with respect to the given field.Field name that defines the ordering relationship.
django/db/models/options.py:139
ordering
The default ordering for the object.List of field names to order by. Prefix with ’-’ for descending order. Use ’?’ for random ordering.
django/db/models/options.py:128
permissions
Extra permissions to enter into the permissions table when creating this object.List of 2-tuples in the format (permission_code, human_readable_permission_name).
django/db/models/options.py:135
proxy
If True, a model that subclasses another model will be treated as a proxy model.If True, creates a proxy model that doesn’t create a new database table.
django/db/models/options.py:148
required_db_features
List of database features that the current connection should have so that the model is considered during migration.List of database feature names required for this model.
django/db/models/options.py:141
required_db_vendor
The name of a supported database vendor that this model is specific to.Database vendor name (e.g., ‘postgresql’, ‘mysql’, ‘sqlite’, ‘oracle’).
django/db/models/options.py:142
select_on_save
Determines if Django will use pre-1.6select behavior when saving objects.
If True, saves will use SELECT to determine whether to INSERT or UPDATE.
django/db/models/options.py:133
indexes
A list of indexes that you want to define on the model.List of Index objects to create on the model’s table.
django/db/models/options.py:130
constraints
A list of constraints that you want to define on the model.List of Constraint objects to apply to the model’s table.
django/db/models/options.py:131
unique_together
Sets of field names that, taken together, must be unique.A list of lists of field names that must be unique together. Deprecated in favor of UniqueConstraint.
django/db/models/options.py:132
verbose_name
A human-readable name for the object, singular.Human-readable name for the model (singular). If not provided, Django creates one from the class name.
django/db/models/options.py:124
verbose_name_plural
The plural name for the object.Human-readable plural name. Defaults to verbose_name + ‘s’.
django/db/models/options.py:125
Read-Only Meta Attributes
These attributes are available onModel._meta but cannot be set in the Meta class:
label
Representation of the model in the formatapp_label.ModelName.
django/db/models/options.py:173
label_lower
Lowercase version of label.django/db/models/options.py:177
object_name
The name of the model class.django/db/models/options.py:136
model_name
Lowercase version of the model name.django/db/models/options.py:123
Methods
get_field()
Returns a field instance given a field name.The name of the field to retrieve.
The Field instance.
django/db/models/options.py:670
get_fields()
Returns a tuple of fields associated with the model.Include fields from parent classes.
Include fields with related_name starting with ’+’.
Tuple of Field instances.
django/db/models/options.py:865