Advertisement
Korotkodul

django перОл models

Jan 18th, 2022 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 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. #x = reverse("univer_info", kwargs={"pk": id})
  15. def __str__(self):
  16. return self.short_name
  17.  
  18. def get_absolute_url(self):
  19.  
  20. #print(x)
  21. return reverse("univer_info", kwargs={"pk": self.id})
  22.  
  23. class Meta:
  24. verbose_name = "Университет"
  25. verbose_name_plural = "Университеты"
  26.  
  27.  
  28.  
  29. class olympiads(models.Model):
  30. id = models.IntegerField("олмипиада", primary_key=True)
  31. name = models.TextField("Название", default="")
  32. url = models.URLField(max_length=150, unique=True,default="")
  33. def __str__(self):
  34. return self.name
  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. class ol_level(models.Model):
  65. id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  66. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  67. id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  68. level = models.IntegerField()
  69.  
  70. class Meta:
  71. verbose_name = "уровень олмипиады"
  72. verbose_name_plural = "уровни олимпиад"
  73.  
  74. class ol_number_int_list(models.Model):
  75. id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  76. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  77. number_in_list = models.IntegerField()
  78. class Meta:
  79. verbose_name = "номер олимпиады в перечне рсош"
  80. verbose_name_plural = "номера олимпиад в перечне рсош"
  81.  
  82.  
  83. class organizer(models.Model):
  84. id = models.IntegerField(primary_key=True)
  85. name = models.TextField()
  86.  
  87. def __str__(self):
  88. return self.name
  89. class Meta:
  90. verbose_name = "организатор"
  91. verbose_name_plural = "организаторы"
  92.  
  93. class ol_organizer(models.Model):
  94. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  95. id_org = models.ForeignKey(organizer,on_delete=models.CASCADE)
  96.  
  97. class Meta:
  98. verbose_name = "организатор олимпиады"
  99. verbose_name_plural = "организаторы олимпиад"
  100.  
  101. class profile(models.Model):
  102. id = models.IntegerField(primary_key=True)
  103. name = models.TextField()
  104.  
  105. def __str__(self):
  106. return self.name
  107.  
  108. class Meta:
  109. verbose_name = "профиль"
  110. verbose_name_plural = "профили"
  111.  
  112. class ol_subj_and_prof(models.Model): #по предмету можем узнать все профили ЭТОЙ олимпиады, которые соответствуют ДЛЯ ЭТОЙ олимпиады ЭТОМУ предмету
  113. id_year = models.ForeignKey(year, on_delete=models.CASCADE)
  114. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  115. id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  116. id_prof = models.ForeignKey(profile, on_delete=models.CASCADE)
  117. class Meta:
  118. verbose_name = "предмет и профиль олимпиады"
  119. verbose_name_plural = "предметы и профили олимпиад"
  120.  
  121. """class profile_of_subject(models.Model):
  122. id_year = models.ForeignKey(year,on_delete=models.CASCADE)
  123. id_ol = models.ForeignKey(olympiads,on_delete=models.CASCADE)
  124. id_subj = models.ForeignKey(subjects,on_delete=models.CASCADE)
  125. id_prof = models.ForeignKey(profile,on_delete=models.CASCADE)
  126.  
  127. class Meta:
  128. verbose_name = "профиль олимпиады"
  129. verbose_name_plural = "профиль олимпиады"
  130. """
  131.  
  132.  
  133.  
  134.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement