Style admin

This commit is contained in:
Gabriel Augendre 2020-08-16 18:39:27 +02:00
parent 10c530bf2e
commit 6444cfe24b
2 changed files with 17 additions and 0 deletions

View file

@ -1,6 +1,8 @@
from django import forms
from django.contrib import admin, messages from django.contrib import admin, messages
from django.contrib.admin import register from django.contrib.admin import register
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.admin import UserAdmin
from django.db import models
from .models import Article, User from .models import Article, User
@ -35,6 +37,11 @@ class ArticleAdmin(admin.ModelAdmin):
("Content", {"fields": ("content",)}), ("Content", {"fields": ("content",)}),
] ]
readonly_fields = ["created_at", "updated_at", "views_count"] readonly_fields = ["created_at", "updated_at", "views_count"]
formfield_overrides = {
models.TextField: {
"widget": forms.Textarea(attrs={"cols": "100", "rows": "50"})
},
}
def publish(self, request, queryset): def publish(self, request, queryset):
if not request.user.has_perm("articles.change_article"): if not request.user.has_perm("articles.change_article"):
@ -58,3 +65,6 @@ class ArticleAdmin(admin.ModelAdmin):
unpublish.short_description = "Unpublish selected articles" unpublish.short_description = "Unpublish selected articles"
actions = [publish, unpublish] actions = [publish, unpublish]
class Media:
css = {"all": ("admin_articles.css",)}

View file

@ -0,0 +1,7 @@
#id_content {
font-family: "JetBrains Mono", monospace;
}
label[for=id_content] {
display: none;
}