Style admin
This commit is contained in:
parent
10c530bf2e
commit
6444cfe24b
2 changed files with 17 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
from django import forms
|
||||
from django.contrib import admin, messages
|
||||
from django.contrib.admin import register
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.db import models
|
||||
|
||||
from .models import Article, User
|
||||
|
||||
|
@ -35,6 +37,11 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
("Content", {"fields": ("content",)}),
|
||||
]
|
||||
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):
|
||||
if not request.user.has_perm("articles.change_article"):
|
||||
|
@ -58,3 +65,6 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
|
||||
unpublish.short_description = "Unpublish selected articles"
|
||||
actions = [publish, unpublish]
|
||||
|
||||
class Media:
|
||||
css = {"all": ("admin_articles.css",)}
|
||||
|
|
7
articles/static/admin_articles.css
Normal file
7
articles/static/admin_articles.css
Normal file
|
@ -0,0 +1,7 @@
|
|||
#id_content {
|
||||
font-family: "JetBrains Mono", monospace;
|
||||
}
|
||||
|
||||
label[for=id_content] {
|
||||
display: none;
|
||||
}
|
Reference in a new issue