带有夏季笔记编辑器的 Django 管理页面导致切换扩展使其看起来很奇怪
Django admin page with summer note editor causing toggle to expand making it look odd
我目前在博客上安装了django summer note。它加载正常,我在控制台中没有看到任何错误,但它看起来像这样 ..
主管理员加载正常,只是创建 post 页面。
我在博客中的 admin.py 文件如下所示
from django.contrib import admin
from .models import Post, Newsletter
from django_summernote.admin import SummernoteModelAdmin
class PostAdmin(SummernoteModelAdmin):
list_display = ('title', 'slug', 'status', 'created_on')
list_filter = ('status', 'created_on')
search_fields = ['title', 'content']
prepopulated_fields = {'slug': ('title',)}
summernote_fields = ('content',)
admin.site.register(Post, PostAdmin)
class NewsletterAdmin(admin.ModelAdmin):
list_display = ('email', 'confirmed')
admin.site.register(Newsletter, NewsletterAdmin)
post 个模型是
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="blog_posts"
)
updated_on = models.DateTimeField(auto_now=True)
content = models.TextField()
created_on = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(choices=STATUS, default=0)
class Meta:
ordering = ["-created_on"]
def __str__(self):
return self.title
def get_absolute_url(self):
from django.urls import reverse
return reverse("post_detail", kwargs={"slug": str(self.slug)})
class Newsletter(models.Model):
email = models.EmailField(null=False, blank=True, max_length=200, unique=True)
conf_num = models.CharField(max_length=15)
confirmed = models.BooleanField(default=False)
def __str__(self):
return self.email + " (" + ("not " if not self.confirmed else "") + "confirmed)"
出于某种原因,我的管理员 CSS 没有完全复制。因此,如果您正确使用 nginx,请确保在收集静态时将其传递给静态。
我目前在博客上安装了django summer note。它加载正常,我在控制台中没有看到任何错误,但它看起来像这样 ..
主管理员加载正常,只是创建 post 页面。
我在博客中的 admin.py 文件如下所示
from django.contrib import admin
from .models import Post, Newsletter
from django_summernote.admin import SummernoteModelAdmin
class PostAdmin(SummernoteModelAdmin):
list_display = ('title', 'slug', 'status', 'created_on')
list_filter = ('status', 'created_on')
search_fields = ['title', 'content']
prepopulated_fields = {'slug': ('title',)}
summernote_fields = ('content',)
admin.site.register(Post, PostAdmin)
class NewsletterAdmin(admin.ModelAdmin):
list_display = ('email', 'confirmed')
admin.site.register(Newsletter, NewsletterAdmin)
post 个模型是
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="blog_posts"
)
updated_on = models.DateTimeField(auto_now=True)
content = models.TextField()
created_on = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(choices=STATUS, default=0)
class Meta:
ordering = ["-created_on"]
def __str__(self):
return self.title
def get_absolute_url(self):
from django.urls import reverse
return reverse("post_detail", kwargs={"slug": str(self.slug)})
class Newsletter(models.Model):
email = models.EmailField(null=False, blank=True, max_length=200, unique=True)
conf_num = models.CharField(max_length=15)
confirmed = models.BooleanField(default=False)
def __str__(self):
return self.email + " (" + ("not " if not self.confirmed else "") + "confirmed)"
出于某种原因,我的管理员 CSS 没有完全复制。因此,如果您正确使用 nginx,请确保在收集静态时将其传递给静态。