This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/articles/admin.py

38 lines
898 B
Python
Raw Normal View History

2020-08-14 14:53:30 +02:00
from django.contrib import admin
2020-08-14 15:53:42 +02:00
from django.contrib.admin import register
2020-08-14 14:53:30 +02:00
from django.contrib.auth.admin import UserAdmin
2020-08-14 15:53:42 +02:00
from .models import Article, User
2020-08-14 14:53:30 +02:00
admin.site.register(User, UserAdmin)
2020-08-14 15:53:42 +02:00
@register(Article)
class ArticleAdmin(admin.ModelAdmin):
list_display = [
"title",
"status",
"author",
"created_at",
"published_at",
"updated_at",
]
list_display_links = ["title"]
list_filter = ["status"]
date_hierarchy = "created_at"
fieldsets = [
(
"Metadata",
{
"fields": (
"title",
"status",
("created_at", "published_at", "updated_at"),
"author",
)
},
),
("Content", {"fields": ("content",)}),
]
readonly_fields = ["created_at", "updated_at"]