diff options
author | Alban Gruin | 2017-01-23 09:13:25 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-23 09:13:25 +0100 |
commit | f2717d6a04d5c463a5b5e8aa41001c0589d3b4c5 (patch) | |
tree | cd5d2e94e8fdabd951b813c6aa21a7013cfb12fe /models.py | |
parent | 1b4731f85718d77db343607e68570797b7e0aae7 (diff) |
Amélioration des clés des modèles
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -37,10 +37,10 @@ class Group(models.Model): name = models.CharField(max_length=255, verbose_name="nom") timetable = models.ForeignKey(Timetable, on_delete=models.CASCADE, verbose_name="emploi du temps") - mention = models.CharField(max_length=32, db_index=True) - subgroup = models.CharField(max_length=1, verbose_name="sous-groupe", db_index=True) - td = models.IntegerField(verbose_name="groupe de TD", null=True, db_index=True) - tp = models.IntegerField(verbose_name="groupe de TP", null=True, db_index=True) + mention = models.CharField(max_length=32) + subgroup = models.CharField(max_length=1, verbose_name="sous-groupe") + td = models.IntegerField(verbose_name="groupe de TD", null=True) + tp = models.IntegerField(verbose_name="groupe de TP", null=True) slug = models.SlugField(max_length=64, unique=True, default="") @@ -67,7 +67,9 @@ class Group(models.Model): class Meta: + index_together = ("mention", "subgroup", "td", "tp",) unique_together = ("name", "timetable",) + verbose_name = "groupe" verbose_name_plural = "groupes" @@ -75,7 +77,7 @@ class Group(models.Model): class Subscription(models.Model): email = models.EmailField(verbose_name="adresse") group = models.ForeignKey(Group, on_delete=models.CASCADE, verbose_name="groupe") - active = models.BooleanField(verbose_name="activé", default=False) + active = models.BooleanField(verbose_name="activé", default=False, db_index=True) token = models.CharField(max_length=64, unique=True, default="") def save(self): @@ -85,7 +87,6 @@ class Subscription(models.Model): class Meta: - index_together = ("group", "active",) unique_together = ("email", "group",) verbose_name = "abonnement" verbose_name_plural = "abonnements" |