diff options
-rw-r--r-- | admin.py | 2 | ||||
-rw-r--r-- | models.py | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -55,7 +55,7 @@ class GroupAdmin(admin.ModelAdmin): @admin.register(Room) class RoomAdmin(admin.ModelAdmin): - pass + prepopulated_fields = {"slug": ("name",)} @admin.register(Course) @@ -142,10 +142,14 @@ class Group(models.Model): class Room(models.Model): name = models.CharField(max_length=255, unique=True, verbose_name="nom") + slug = models.SlugField(max_length=64, default="", unique=True) def __str__(self): return self.name + def save(self, *args, **kwargs): + self.slug = slugify(self.name) + super(Room, self).save() class Meta: verbose_name = "salle" |