6
0

saved_sportsman.py 917 B

1234567891011121314151617
  1. from django.db import models
  2. from webservice_running.models import Sportsman
  3. class SavedSportsman(models.Model):
  4. """
  5. Соединяющая таблица двух пользователей для реализации функционала сохранения пользователя в список сохранённых
  6. """
  7. sportsman = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_savedsportsman")
  8. sportsman_saved = models.ForeignKey(Sportsman, on_delete=models.DO_NOTHING, related_name="sportsman_saved")
  9. class Meta:
  10. db_table = "saved_sportsman"
  11. verbose_name = "сохранённый ползователь"
  12. verbose_name_plural = "сохранённые пользователи"
  13. constraints = [
  14. models.UniqueConstraint(fields=['sportsman', 'sportsman_saved'], name='unique_saved_sportsman')
  15. ]