typeidea icon indicating copy to clipboard operation
typeidea copied to clipboard

115页 6.1.2 报错呢。。

Open weisong5908 opened this issue 5 years ago • 3 comments

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

weisong5908 avatar Aug 14 '20 03:08 weisong5908

那个是target吧,不是traget。

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

MaoningGuan avatar Aug 14 '20 06:08 MaoningGuan

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

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

weisong5908 avatar Aug 14 '20 11:08 weisong5908

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

MaoningGuan avatar Aug 16 '20 14:08 MaoningGuan