Meta Django model of the common options

ordering

This field is to tell Django model objects returned result set of records of which field is sorted. This is the tuple or a list of strings, a string is not a field, and with an optional show descending '-' configuration. When the field name without a preceding '-' is used by default in ascending order. Use the '?' Will be randomly arranged

  • ordering = [ 'order_date'] # are arranged in ascending order
  • ordering = [ '- order_date'] # are arranged in descending order, - indicates descending

verbose_name

verbose_name meaning is very simple, is to give your model classes from a more readable name is usually defined as the Chinese, we have:
verbose_name = "school"

verbose_name_plural

This option is specified, what is the plural form of the model, such as:
verbose_name_plural = "school"
If you do not specify Django will automatically add an 's' after the model name

Guess you like

Origin www.cnblogs.com/sunnyyangwang/p/11224206.html