Korotkodul

django перОл models 2

Jan 20th, 2022 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. from django.db import models
  2. from django.urls import reverse
  3.  
  4. # Create your models here.
  5.  
  6. class University(models.Model):
  7. id = models.IntegerField("Id", primary_key= True)
  8. short_name = models.CharField("Сокращенное название", max_length=50)
  9. full_name = models.TextField("Полное название", max_length=250)
  10. address = models.CharField("Адрес", max_length=150)
  11. phone = models.CharField("Телефон", max_length=50)
  12. url = models.URLField(max_length=150, unique=True,default="")
  13. country = models.CharField("Страна", max_length=50, default="")
  14.  
  15. def __str__(self):
  16. return self.short_name
  17.  
  18. def get_absolute_url(self):
  19. return reverse("univer_info", kwargs={"pk": self.id})
  20.  
  21. class Meta:
  22. verbose_name = "Университет"
  23. verbose_name_plural = "Университеты"
  24.  
  25.  
  26.  
  27. class olympiads(models.Model):
  28. id = models.IntegerField("олмипиада", primary_key=True)
  29. name = models.TextField("Название", default="")
  30. url = models.URLField(max_length=150, unique=True,default="")
  31.  
  32. def __str__(self):
  33. return self.name
  34.  
  35. class Meta:
  36. verbose_name = "Олимпиада"
  37. verbose_name_plural = "Олимпиады"
  38.  
  39.  
  40. class subjects(models.Model):
  41. id = models.IntegerField(primary_key=True)
  42. name = models.TextField()
  43.  
  44. def __str__(self):
  45. return self.name
  46.  
  47. class Meta:
  48. verbose_name = "УПредмет"
  49. verbose_name_plural = "Предметы"
  50.  
  51.  
  52. class year(models.Model):
  53. id = models.IntegerField(primary_key=True)
  54. num_of_year = models.IntegerField(default=0)
  55. number_of_order = models.TextField()
  56.  
  57. def __str__(self):
  58. return self.num_of_year
  59.  
  60. class Meta:
  61. verbose_name = "Год"
  62. verbose_name_plural = "Годы"
  63.  
  64.  
  65.  
  66. class ol_number_int_list(models.Model):
  67. id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  68. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  69. number_in_list = models.IntegerField()
  70. class Meta:
  71. verbose_name = "номер олимпиады в перечне рсош"
  72. verbose_name_plural = "номера олимпиад в перечне рсош"
  73.  
  74.  
  75. class organizer(models.Model):
  76. id = models.IntegerField(primary_key=True)
  77. name = models.TextField()
  78.  
  79. def __str__(self):
  80. return self.name
  81. class Meta:
  82. verbose_name = "организатор"
  83. verbose_name_plural = "организаторы"
  84.  
  85. class ol_organizer(models.Model):
  86. id_year = models.ForeignKey(year, on_delete=models.CASCADE, default="")
  87. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE, default="")
  88. id_org = models.ForeignKey(organizer,on_delete=models.CASCADE, default="")
  89.  
  90. class Meta:
  91. verbose_name = "организатор олимпиады"
  92. verbose_name_plural = "организаторы олимпиад"
  93.  
  94. class profile(models.Model):
  95. id = models.IntegerField(primary_key=True)
  96. name = models.TextField()
  97.  
  98. def __str__(self):
  99. return self.name
  100.  
  101. class Meta:
  102. verbose_name = "профиль"
  103. verbose_name_plural = "профили"
  104.  
  105. class ol_info(models.Model): #по предмету можем узнать все профили ЭТОЙ олимпиады, которые соответствуют ДЛЯ ЭТОЙ олимпиады ЭТОМУ предмету
  106. id_year = models.ForeignKey(year, on_delete=models.CASCADE)
  107. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  108. id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  109. id_prof = models.ForeignKey(profile, on_delete=models.CASCADE)
  110. level = models.IntegerField(default="")
  111.  
  112. class Meta:
  113. verbose_name = "год, предмет, профиль, уровень олимпиады"
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
Add Comment
Please, Sign In to add comment