Show proper name for bookmark assets in admin (#708)

This commit is contained in:
ab623 2024-04-17 22:18:23 +01:00 committed by GitHub
parent 9dc3521d5e
commit 0586983602
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View file

@ -200,9 +200,13 @@ class AdminBookmark(admin.ModelAdmin):
class AdminBookmarkAsset(admin.ModelAdmin):
list_display = ("display_name", "date_created", "status")
@admin.display(description="Display Name")
def custom_display_name(self, obj):
return str(obj)
list_display = ("custom_display_name", "date_created", "status")
search_fields = (
"display_name",
"custom_display_name",
"file",
)
list_filter = ("status",)

View file

@ -118,6 +118,9 @@ class BookmarkAsset(models.Model):
pass
super().save(*args, **kwargs)
def __str__(self):
return self.display_name or f"Bookmark Asset #{self.pk}"
@receiver(post_delete, sender=BookmarkAsset)
def bookmark_asset_deleted(sender, instance, **kwargs):