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 = True
blank = True
choices = (('db_val', 'displayed_val'), )
db_column = "string"
db_index = True
default = "string"
editable = False
primary_key = True
unique = True
verbose_name = "String"
Field Types and Options
AutoField
BooleanField
CharField (max_length=integer)
DateField|DateTimeField(auto_now_add=True)
IPAddressField
PositiveIntegerField
TextField
ForeignKey(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.