Use of meta class in django
https://stackoverflow.com/questions/2146363
OTHER TIPS
Django models use the Meta
class to contain extra information about the model that would not necessarily be appropriate to contain within the model class itself. Note that this is not the same as Python's metaclass
; that is a completely different topic.
In this case it ordering or sorting the queries to this model by field "Gender"
In this case it defines the default field for ordering if you don't provide ORDER_BY
in your query.
It is explained in Django Documentation for Models
https://docs.djangoproject.com/en/dev/topics/db/models/
Give your model metadata by using an inner class Meta, like:
Class Employee (models.Model):
....
class Meta:
ordering = ["attribute-X"]
Another useful option can be used in class Meta is verbose_name.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow