关于django里查询问题Exception Value: 'list' object has no attribute '
DjangoVersion:1.3.1ExceptionType:AttributeErrorExceptionValue:'list'objecthasnoattrib...
Django Version: 1.3.1
Exception Type: AttributeError
Exception Value:
'list' object has no attribute 'status_code'
---------------------------------------------------
model:
class news_list(models.Model):
title = models.CharField(max_length=250, unique=True)
def __str__(self):
return self.title
class news_listAdmin(admin.ModelAdmin):
list_display = ('title',)
admin.site.register(news_list,news_listAdmin)
class news_item(models.Model):
title = models.CharField(max_length=250)
body= models.TextField()
created_date = models.DateTimeField(default=datetime.datetime.now)
completed = models.BooleanField(default=False)
article_list = models.ForeignKey(news_list)
class Meta:
ordering = ['-created_date', 'title']
def __str__(self):
return self.title
class news_itemAdmin(admin.ModelAdmin):
list_display = ('title','article_list','created_date')
admin.site.register(news_item,news_itemAdmin)
views:
this_new = news_list.objects.all()
return render_to_response("news/list.html", {'news':this_new})
其它的查询都能成功,为什么把一个class作为外键就不能查询了,求解 展开
Exception Type: AttributeError
Exception Value:
'list' object has no attribute 'status_code'
---------------------------------------------------
model:
class news_list(models.Model):
title = models.CharField(max_length=250, unique=True)
def __str__(self):
return self.title
class news_listAdmin(admin.ModelAdmin):
list_display = ('title',)
admin.site.register(news_list,news_listAdmin)
class news_item(models.Model):
title = models.CharField(max_length=250)
body= models.TextField()
created_date = models.DateTimeField(default=datetime.datetime.now)
completed = models.BooleanField(default=False)
article_list = models.ForeignKey(news_list)
class Meta:
ordering = ['-created_date', 'title']
def __str__(self):
return self.title
class news_itemAdmin(admin.ModelAdmin):
list_display = ('title','article_list','created_date')
admin.site.register(news_item,news_itemAdmin)
views:
this_new = news_list.objects.all()
return render_to_response("news/list.html", {'news':this_new})
其它的查询都能成功,为什么把一个class作为外键就不能查询了,求解 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询