diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -71,7 +71,7 @@ class Timetable(SlugModel): class GroupManager(Manager): def get_parents(self, group): - groups_criteria = Q(subgroup__isnull=True) | Q(subgroup__startswith=group.subgroup) | \ + groups_criteria = Q(subgroup="") | Q(subgroup__startswith=group.subgroup) | \ reduce(lambda x, y: x | y, [Q(subgroup=group.subgroup[:i]) for i in range(1, len(group.subgroup) + 1)]) @@ -99,8 +99,7 @@ class Group(models.Model): verbose_name="emploi du temps") mention = models.CharField(max_length=128) - subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", - null=True) + subgroup = models.CharField(max_length=16, verbose_name="sous-groupe", default="") slug = models.SlugField(max_length=64, default="") @@ -129,6 +128,9 @@ class Group(models.Model): self.slug = slugify(self.name) self.mention, self.subgroup = parse_group(self.name) + if self.subgroup is None: + self.subgroup = "" + super(Group, self).save() |