the5fire / typeidea

Django企业开发实战对应项目代码
http://django-practice-book.com/
Other
439 stars 214 forks source link

FieldError 字段错误,找了两个小时,实在不知道哪里错了。 #55

Open weisong5908 opened 4 years ago

weisong5908 commented 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.

求大神帮我看看吧。。。。

MaoningGuan commented 4 years ago

Unknown field(s) (content) specified for Post 找不到content这个字段,看一下post model有没有这个content字段,或者有没有拼写错误