Korotkodul

IT. Simple Data

Dec 16th, 2021 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.95 KB | None | 0 0
  1. from django.db import models
  2.  
  3. # Create your models here.
  4. #возьми олимпиады, где только один организатор
  5. class University(models.Model):
  6.  
  7.     short_name = models.CharField("Сокращенное название", max_length=50)
  8.     full_name = models.TextField("Полное название", max_length=250)
  9.     address = models.CharField("Адрес", max_length=150)
  10.     phone = models.CharField("Телефон", max_length=50)
  11.     url = models.URLField(max_length=150, unique=True)
  12.  
  13.     def __str__(self):
  14.         return self.short_name
  15.  
  16.     class Meta:
  17.         verbose_name = "Университет"
  18.         verbose_name_plural = "Университеты"
  19.  
  20.  
  21. class olympiads(models.Model):
  22.     id = models.IntegerField(primary_key=True)
  23.     name = models.TextField()
  24.     url = models.URLField(max_length=150, unique=True,default="")
  25.     def __str__(self):
  26.         return self.name
  27.  
  28.  
  29. class subjects(models.Model):
  30.     id = models.IntegerField(primary_key=True)
  31.     name = models.TextField()
  32.  
  33.     def __str__(self):
  34.         return self.name
  35.  
  36.  
  37. class year(models.Model):
  38.     id = models.IntegerField(primary_key=True)
  39.     num_of_year = models.IntegerField(default=0)
  40.     number_of_order = models.TextField()
  41.  
  42.     def __str__(self):
  43.         return self.num_of_year
  44.  
  45. class ol_level(models.Model):
  46.     id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  47.     id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  48.     id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  49.     level = models.IntegerField()
  50.  
  51. class ol_number_int_list(models.Model):
  52.     id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  53.     id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  54.     number_in_list = models.IntegerField()
  55.  
  56.  
  57. class organizer(models.Model):
  58.     id = models.IntegerField(primary_key=True)
  59.     name = models.TextField()
  60.  
  61.     def __str__(self):
  62.         return self.name
  63.  
  64. class ol_organizer(models.Model):
  65.     id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  66.     id_org = models.ForeignKey(organizer,on_delete=models.CASCADE)
  67.  
  68. class profile(models.Model):
  69.     id = models.IntegerField(primary_key=True)
  70.     name = models.TextField()
  71.  
  72.     def __str__(self):
  73.         return self.name
  74.  
  75. class ol_subj(models.Model): #по предмету можем узнать все профили ЭТОЙ олимпиады, которые соответствуют ДЛЯ ЭТОЙ олимпиады ЭТОМУ предмету
  76.     id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  77.     id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  78.  
  79. class profile_of_subject(models.Model):
  80.     id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  81.     id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  82.     id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  83.     id_prof = models.ForeignKey(profile,on_delete=models.CASCADE)
  84.  
  85.  
  86.  
  87.  
Add Comment
Please, Sign In to add comment