Skip to content

Commit

Permalink
🩹(backend) enhance Django Admin for Team Slug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lebaudantoine committed Feb 12, 2024
1 parent a7d72d0 commit d1cc194
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
2 changes: 1 addition & 1 deletion src/backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d1cc194

Please sign in to comment.