I’ve been working on a small Django app recently, and started by cleaning up its model definitions. Here’s a quick (but not exhaustive) list of useful configuration options:
Model Meta Options
db_table = "string"managed = False(whether SQL is generated by the manage.py app)ordering = ['column1', '-column2'](NB admin app only uses the first)order_with_respect_to = 'fk_field'unique_together = (('column1', 'column2'), )verbose_name = "String"verbose_name_plural = "String"abstract = True
Common Field Options
null = Trueblank = Truechoices = (('db_val', 'displayed_val'), )db_column = "string"db_index = Truedefault = "string"editable = Falseprimary_key = Trueunique = Trueverbose_name = "String"
Field Types and Options
AutoFieldBooleanFieldCharField (max_length=integer)DateField|DateTimeField(auto_now_add=True)IPAddressFieldPositiveIntegerFieldTextFieldForeignKey(Class, to_field='related_field')ManyToManyField(Class, to_field='related_field')
For further details, see the Models documentation, Meta Options documentation and Field Types documentation.