We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
@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.
求大神帮我看看吧。。。。
The text was updated successfully, but these errors were encountered:
Unknown field(s) (content) specified for Post 找不到content这个字段,看一下post model有没有这个content字段,或者有没有拼写错误
Sorry, something went wrong.
No branches or pull requests
@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.
求大神帮我看看吧。。。。
The text was updated successfully, but these errors were encountered: