def index(request): latest_question_list = Question.objects.all().order_by('-pub_date')[:5] template = loader.get_template('polls/index.html') context = {'latest_question_list':latest_question_list} return HttpResponse(template.render(context, request))
The first line of this function receives an error in Question.objects.all () -> E1101: Class' Question has no objects member`
Im following the Django documentation tutorial and they have the same code that works and works.
I tried to call an instance.
Question = new Question() and using MyModel.objects.all()
Also my models.py code for this class is ...
class Question(models.Model): question_text = models.CharField(max_length = 200) pub_date = models.DateTimeField('date published') def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1) def __str__(self): return self.question_text
To no avail, I still have this error.
I read about pylint and ran this ...
pylint --load-plugins pylint_django
Which didn't help, even the readme github file says ...
Prevents warnings about Django-generated attributes such as Model.objects or Views.request.
I executed a command in my virtual space, but nothing.
So any help would be great
source share