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 ...
,所以你已经 覆盖 了对该类的引用。 - Willem Van Onsem