diff options
author | Alban Gruin | 2017-09-07 22:46:54 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-07 22:46:54 +0200 |
commit | ec90d2b98716ef88a3c7f4f673042c04dcbde03a (patch) | |
tree | ffd2f720a12ba35faf8132705ee5044bf0c4e935 /models.py | |
parent | 36b4c60aacae827b5ff8b6125bdfd70d7cf2a3a0 (diff) |
Création d’un modèle année pour remplacer le champ année des emplois
du temps
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -25,22 +25,30 @@ import hashlib import os +class Year(models.Model): + name = models.CharField(max_length=16, verbose_name="année") + slug = models.SlugField(max_length=16, unique=True, default="") + + def __str__(self): + return self.name + + + class Meta: + verbose_name = "année" + verbose_name_plural = "années" + + class Timetable(models.Model): - year = models.CharField(max_length=16, verbose_name="année") - name = models.CharField(max_length=64, verbose_name="nom") + year = models.ForeignKey(Year, verbose_name="année") + name = models.CharField(max_length=64, unique=True, verbose_name="nom") url = models.URLField(max_length=255, unique=True, verbose_name="URL") slug = models.SlugField(max_length=64, unique=True, default="") def __str__(self): - return self.full_name() - - def full_name(self): - return self.year + " " + self.name + return self.name - full_name.short_description = "Nom complet" class Meta: - unique_together = ("year", "name",) verbose_name = "emploi du temps" verbose_name_plural = "emplois du temps" |