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

115页 6.1.2 报错呢。。 #54

Open
weisong5908 opened this issue Aug 14, 2020 · 3 comments
Open

115页 6.1.2 报错呢。。 #54

weisong5908 opened this issue Aug 14, 2020 · 3 comments

Comments

@weisong5908
Copy link

from django.contrib import admin

from .models import Comment

@admin.register(Comment)

class CommentAdmin(admin.ModelAdmin):

list_display = ('traget','nickname','content','website','created_time')

按书上教程敲的代码。
到这里就报错了。。。

ERRORS:
<class 'comment.admin.CommentAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'traget', which is not a callable, an attribute of 'CommentAdmin', or an attribute or method on 'comment.Comment'.

@MaoningGuan
Copy link

那个是target吧,不是traget。

Django的错误提示已经很明白了。

@weisong5908
Copy link
Author

不光这个,还有书上代码。92页

target = models.ForeignKey(Post,verbose_name="评论目标") 好像也不对

@MaoningGuan
Copy link

MaoningGuan commented Aug 16, 2020

应该是ForeignKey这个引用外键在django 2 这个版本改变了,具体的我忘记了,你可以看看作者github这里的代码

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