From 6444cfe24b0c79f3ae49dfe8b20f885edfc594ee Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 16 Aug 2020 18:39:27 +0200 Subject: [PATCH] Style admin --- articles/admin.py | 10 ++++++++++ articles/static/admin_articles.css | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 articles/static/admin_articles.css diff --git a/articles/admin.py b/articles/admin.py index 8e77718..862b341 100644 --- a/articles/admin.py +++ b/articles/admin.py @@ -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",)} diff --git a/articles/static/admin_articles.css b/articles/static/admin_articles.css new file mode 100644 index 0000000..a30f3f4 --- /dev/null +++ b/articles/static/admin_articles.css @@ -0,0 +1,7 @@ +#id_content { + font-family: "JetBrains Mono", monospace; +} + +label[for=id_content] { + display: none; +}