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 :: strings are immutable in python 
Python :: mouse bottom in pygame 
Python :: example of django template for forms 
Python :: create spark dataframe from pandas 
Python :: create new dataframe from existing dataframe pandas 
Python :: Read text file line by line using the readline() function 
Python :: python logger get level 
Python :: django group by 
Python :: dense rank in pandas 
Python :: armstrong python 
Python :: hello world in python 
Python :: convert dict to string python 
Python :: python get desktop directory 
Python :: python how to import library absoluth path 
Python :: print map object python 
Python ::  in python 
Python :: read excel into dataframe python 
Python :: pandas dataframe read string as date 
Python :: pandas change to numeric 
Python :: elif in django template 
Python :: how to append list to list in python 
Python :: check if path exists python 
Python :: how to make django model field case insensitive 
Python :: python push to list 
Python :: how to get unique value of all columns in pandas 
Python :: json url to dataframe python 
Python :: python list length 
Python :: get tail of dataframe pandas 
Python :: limit for loop python 
Python :: how to make table using python 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =