add: поле updated_at (Дата обновления) в модели +миграции, админке, блогах, страницах и sitemaps.xml
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
import html
|
||||
from .models import Post
|
||||
|
||||
@admin.register(Post)
|
||||
class PostAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'post_type', 'is_published', 'published_at')
|
||||
list_display = ('clean_title', 'post_type', 'is_published', 'published_at', 'updated_at')
|
||||
list_filter = ('post_type', 'is_published', 'published_at')
|
||||
search_fields = ('title', 'content', 'slug')
|
||||
prepopulated_fields = {'slug': ('title',)}
|
||||
date_hierarchy = 'published_at'
|
||||
readonly_fields = ('updated_at',)
|
||||
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('title', 'slug', 'post_type', 'is_published', 'published_at')
|
||||
'fields': ('title', 'slug', 'post_type', 'is_published', 'published_at', 'updated_at')
|
||||
}),
|
||||
('Контент', {
|
||||
'fields': ('image', 'excerpt', 'content')
|
||||
@@ -21,3 +24,8 @@ class PostAdmin(admin.ModelAdmin):
|
||||
'classes': ('collapse',)
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.display(description='Заголовок', ordering='title')
|
||||
def clean_title(self, obj):
|
||||
"""Отображает заголовок без HTML-сущностей ( -> пробел)."""
|
||||
return html.unescape(obj.title)
|
||||
|
||||
Reference in New Issue
Block a user