Skip to content

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

Description

@weisong5908

@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.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions