From db5d21f74b8bc577c27979d88623a34df99ac245 Mon Sep 17 00:00:00 2001 From: Lebaud Antoine Date: Mon, 12 Feb 2024 10:35:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(backend)=20enhance=20Django=20Admi?= =?UTF-8?q?n=20for=20Team=20Slug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make Team's Slug field non-editable in the Django admin. It avoid UX issues by preventing accidental slug overwrites during updates. The Slug is now displayed in the teams list view. --- src/backend/core/admin.py | 2 +- src/backend/core/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/core/admin.py b/src/backend/core/admin.py index 075d8c2f4..5ab86bb3d 100644 --- a/src/backend/core/admin.py +++ b/src/backend/core/admin.py @@ -105,8 +105,8 @@ class TeamAdmin(admin.ModelAdmin): inlines = (TeamAccessInline,) list_display = ( "name", + "slug", "created_at", "updated_at", ) - prepopulated_fields = {"slug": ("name",)} search_fields = ("name",) diff --git a/src/backend/core/models.py b/src/backend/core/models.py index d2889ece3..f9f7cdeee 100644 --- a/src/backend/core/models.py +++ b/src/backend/core/models.py @@ -316,7 +316,7 @@ class Team(BaseModel): """ name = models.CharField(max_length=100) - slug = models.SlugField(max_length=100, unique=True, null=False) + slug = models.SlugField(max_length=100, unique=True, null=False, editable=False) users = models.ManyToManyField( User,