Open weisong5908 opened 4 years ago
@admin.register(Post) class PostAdmin(admin.ModelAdmin): list_display = [ 'title','category','status', 'created_time','operator' ] list_display_links = [] list_filter = ['category',] search_fields = ['title','category__name'] actions_on_top = True actions_on_bottom = True save_on_top = True fields = ( ('category','title'), 'desc', 'status', 'content', 'tag', ) def operator(self,obj): return format_html( '编辑', reverse('admin:blog_post_change',args=(obj.id,)) ) operator.short_description = '操作'
def save_model(self, request, obj, form, change): obj.owner = request.user return super(PostAdmin, self).save_model(request,obj,form,change)
报错:django.core.exceptions.FieldError: Unknown field(s) (content) specified for Post. Check fields/fieldsets/exclude attributes of class PostAdmin.
求大神帮我看看吧。。。。
Unknown field(s) (content) specified for Post 找不到content这个字段,看一下post model有没有这个content字段,或者有没有拼写错误
@admin.register(Post) class PostAdmin(admin.ModelAdmin):
list_display = [ 'title','category','status', 'created_time','operator' ]
list_display_links = []
list_filter = ['category',]
search_fields = ['title','category__name']
actions_on_top = True
actions_on_bottom = True
save_on_top = True
fields = ( ('category','title'), 'desc', 'status', 'content', 'tag', )
def operator(self,obj): return format_html( '编辑', reverse('admin:blog_post_change',args=(obj.id,)) )
operator.short_description = '操作'
def save_model(self, request, obj, form, change): obj.owner = request.user return super(PostAdmin, self).save_model(request,obj,form,change)
报错:django.core.exceptions.FieldError: Unknown field(s) (content) specified for Post. Check fields/fieldsets/exclude attributes of class PostAdmin.
求大神帮我看看吧。。。。