Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django model inheritance

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
    age = models.PositiveIntegerField()

    class Meta:
        abstract = True
        ordering = ['name']

class Unmanaged(models.Model):
    class Meta:
        abstract = True
        managed = False

class Student(CommonInfo, Unmanaged):
    home_group = models.CharField(max_length=5)

    class Meta(CommonInfo.Meta, Unmanaged.Meta):
        pass
Comment

PREVIOUS NEXT
Code Example
Python :: mongoengine 
Python :: python line number 
Python :: Insert list element at specific index 
Python :: python catch any exception 
Python :: promises in python 
Python :: Python Read the CSV file 
Python :: to divide or not to divide codechef 
Python :: how to replace a string in py 
Python :: __repr__ in python 
Python :: how many numbers greater than 100 using pytho 
Python :: Difference between append() and extend() method in Python 
Python :: PHP echo multiple lines example Using Nowdoc 
Python :: use functions to resample pandas 
Python :: lose your django secret key 
Python :: how to get a row of a dataframe with subset columns in python 
Python :: python day of the year 
Python :: tkinter add text to canvas 
Python :: pandas shape 
Python :: how stract avery .jpg string in a website python 
Python :: python flatten one liner 
Python :: how to convert a string to a list python 
Python :: telegram.ext package 
Python :: list all placeholders python pptx 
Python :: get single batch from torch data loader 
Python :: python convert xml to dictionary 
Python :: Flatten List in Python Using NumPy concatenate 
Python :: python build a string using reduce and concatenate 
Python :: how to combine two lists in one python 
Python :: Average of total in django querysets 
Python :: python defualt error handler 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =