Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
weisong5908 opened this issue Aug 14, 2020 · 1 comment

Comments

@weisong5908
Copy link

@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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants