python class meta django code example
Example 1: what does class meta do in django
from django.db import models
class Ox(models.Model):
horn_length = models.IntegerField()
class Meta:
ordering = ["horn_length"]
verbose_name_plural = "oxen"
//Model metadata is “anything that’s not a field”, such as ordering options (ordering), database table name (db_table), or human-readable singular and plural names (verbose_name and verbose_name_plural). None are required, and adding class Meta to a model is completely optional.
Example 2: django meta attributes
abstract
app_label
base_manager_name
db_table
Table names
db_tablespace
default_manager_name
default_related_name
get_latest_by
managed
order_with_respect_to
ordering
permissions
default_permissions
proxy
required_db_features
required_db_vendor
select_on_save
indexes
unique_together
index_together
constraints
verbose_name
verbose_name_plural