Fix: post title in django admin page
This commit is contained in:
parent
9a2759bb21
commit
0cdbccdd6e
1 changed files with 9 additions and 1 deletions
|
@ -52,7 +52,7 @@ class PostAdmin(admin.ModelAdmin):
|
||||||
"post_id",
|
"post_id",
|
||||||
"source_site",
|
"source_site",
|
||||||
"creator",
|
"creator",
|
||||||
"title",
|
"title_at",
|
||||||
"description_at",
|
"description_at",
|
||||||
"mature",
|
"mature",
|
||||||
"date_created_fromated",
|
"date_created_fromated",
|
||||||
|
@ -60,6 +60,14 @@ class PostAdmin(admin.ModelAdmin):
|
||||||
"date_last_import_formated",
|
"date_last_import_formated",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@admin.display(description="Title")
|
||||||
|
def title_at(self, obj):
|
||||||
|
if obj.title.first() is not None:
|
||||||
|
if len(str(obj.title.first().content)) >= 80:
|
||||||
|
return obj.title.first().content[:77] + "..."
|
||||||
|
else:
|
||||||
|
return obj.title.first().content
|
||||||
|
|
||||||
@admin.display(description="Description")
|
@admin.display(description="Description")
|
||||||
def description_at(self, obj):
|
def description_at(self, obj):
|
||||||
if len(str(obj.description.first().content)) >= 80:
|
if len(str(obj.description.first().content)) >= 80:
|
||||||
|
|
Loading…
Add table
Reference in a new issue