SHARE
TWEET

Django Model Design

asadlive84 Oct 27th, 2017 (edited) 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.db import models
  2.  
  3. # Create your models here.
  4.  
  5.  
  6. class Student(models.Model):
  7.     STD_CLASS=(
  8.         ('6','SIX'),
  9.         ('7','Seven'),
  10.         ('8', 'Eight'),
  11.         ('9', 'Nine'),
  12.         ('10', 'Ten'),
  13.         ('10X', 'ExTen'),
  14.  
  15.     )
  16.  
  17.     GROUP_NAME = (
  18.         ('S','SCIENCE'),
  19.         ('H','Humatics'),
  20.         ('B','Business'),
  21.         ('G','GENEREL'),
  22.     )
  23.     std_name=models.CharField('Student Full Name',max_length=100)
  24.     std_class=models.CharField('Student Class',max_length=2, choices=STD_CLASS)
  25.     std_roll_number=models.IntegerField('Roll Number')
  26.     std_group = models.CharField('Student Group',max_length=1, choices=GROUP_NAME)
  27.     std_gpa = models.CharField('Student GPA GRADE',max_length=3, blank=True, null=True)
  28.     std_gpa_point = models.DecimalField('Student GPA Point',default=0, max_digits=3, decimal_places=2)
  29.     std_total_marks = models.IntegerField('Student Total Marks',default=0)
  30.  
  31.  
  32.     def __str__(self):
  33.         return self.std_name
  34.  
  35.  
  36. class StudentSubject(models.Model):
  37.     subject_name=models.CharField('Subject Name',max_length=50)
  38.     subject_full_marks=models.IntegerField('Full Marks')
  39.     subject_marks=models.IntegerField('')
  40.  
  41.     #add forign key
  42.     student=models.ForeignKey(Student,on_delete=models.CASCADE)
  43.  
  44.     def __str__(self):
  45.         return self.subject_name
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top