Django Model Meta Options

By: Dusty Arlia
Published on Thursday, April 10, 2014, 08:03 PM
Last Updated on Tuesday, July 07, 2015 at 10:31 PM
Total Updates: 2

Model metadata is optional information about your model that is not a field (e.g. ordering, db_table, verbose_name, and verbose_name_plural). Add metadata to your Django model by using an inner class named Meta. Here is an example:

from django.db import models

class User(models.Model):
    age = models.IntegerField()

    class Meta:
        ordering = ["age"]
		verbose_name_plural = "users"

Comments:

Ad:

Ad: