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
Gabriel Augendre 7ab0f6ee24 Add a views count on article
Incremented by non logged in visitors
2020-08-14 22:06:38 +02:00

37 lines
930 B
Python

from django.contrib import admin
from django.contrib.admin import register
from django.contrib.auth.admin import UserAdmin
from .models import Article, User
admin.site.register(User, UserAdmin)
@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",
("author", "status"),
("published_at", "created_at", "updated_at"),
"views_count",
)
},
),
("Content", {"fields": ("content",)}),
]
readonly_fields = ["created_at", "updated_at", "views_count"]