【发布时间】:2018-08-13 18:41:23
【问题描述】:
from django.http import HttpResponse
from .models import Destination
def index(request):
boards = Destination.objects.all()
boards_names = list()
for Destination in boards:
boards_names.append(Destination.destinationtext)
response_html = '<br>'.join(boards_names)
return HttpResponse(response_html)
我编写此代码只是为了练习 django 框架,但我通过 pylint 收到以下错误:
E1101:Class 'Destination' has no 'objects' member
E0601:Using variable 'Destination' before assignment
【问题讨论】:
-
你写了
for Destination in ...,所以你覆盖了对类的引用。
标签: python django django-views