I noticed Django-Summernote that I was willing to use in Django Admin prevents PostAdmin from working properly. As soon as I try to replace the default content field with the Summernote one, Auto-Slug stops working and most of the posted contents' texts are not shown. I did a quick search and unfortunately, I could not figure out a way to solve this issue. Therefore, I would be glad if you guys tell me what's wrong.
This is my admin.py :
from django.contrib import admin
from .models import Post
from django.contrib import admin
from django_summernote.admin import SummernoteModelAdmin
class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'slug', 'status','created_on')
list_filter = ("status",)
search_fields = ['title', 'content']
prepopulated_fields = {'slug': ('title',)}
class PostAdmin(SummernoteModelAdmin):
summernote_fields = ('content',)
admin.site.register(Post, PostAdmin)
The SummernoteModelAdmin has the features of ModelAdmin so no need to create PostAdmin class twice. Simply replace admin.ModelAdmin with SummernoteModelAdmin in the PostAdmin class and add the summernote_fields variable to the existing variables like this:
class PostAdmin(SummernoteModelAdmin):
list_display = ('title', 'slug', 'status', 'created_on')
list_filter = ("status",)
search_fields = ['title', 'content']
prepopulated_fields = {'slug': ('title',)}
summernote_fields = ('content',)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.