-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
from django.contrib import admin | ||
from django.template.defaultfilters import truncatechars | ||
|
||
from message.models import Message | ||
|
||
|
||
@admin.register(Message) | ||
class MessageURLAdmin(admin.ModelAdmin): | ||
|
||
# Define a method to truncate content | ||
def short_content(self, obj): | ||
return truncatechars(obj.content, 35) | ||
|
||
short_content.short_description = 'Short Content' # Optional: Customize the column header | ||
|
||
# Display the new fields in the admin list view | ||
list_display = ('slug', 'short_content', 'created_at') | ||
search_fields = ('slug', 'content') | ||
list_filter = ['created_at'] | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters