Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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.
Comment

django meta attributes

# All Django Class 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
Comment

purpose of meta class in django

purpose of meta class in django

Model Meta is basically the inner class of your model class. 
Model Meta is basically used to change the behavior of your model fields like changing order options,verbose_name and lot of other options. 
It's completely optional to add Meta class in your model
Comment

PREVIOUS NEXT
Code Example
Python :: while loop py 
Python :: python suppress warnings in function 
Python :: how to parse timestamp in python 
Python :: for if else one line python 
Python :: list_display django foreign key 
Python :: import matlab python 
Python :: pandas not a time nat 
Python :: matplotlib legend number columns 
Python :: jupyter today date 
Python :: pack tkinter 
Python :: indexing python first and last 
Python :: how to print in double quotes in python 
Python :: comment lister les fichiers un dossier avec python 
Python :: character in string python 
Python :: piecewise linear regression python 
Python :: python int to char 
Python :: use gpu for python code in vscode 
Python :: python list files in directory 
Python :: swap 2 no in one line python 
Python :: opening files in python 
Python :: python dictionary comprehensions 
Python :: python basic flask web 
Python :: django abstractuser 
Python :: how to make a button open a new window in python 
Python :: python list contains string 
Python :: python . 
Python :: python convert list of lists of strings to int 
Python :: channel hide command in discord.py 
Python :: Difference between two dates and times in python 
Python :: converting datatypes 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =