On Tue, 22 Oct 2019, 21:02 Olivier Dugast, <arnolix.fr@gmail.com> wrote:
--
Le mercredi 10 juillet 2019 13:26:53 UTC+2, Solomon Mbak a écrit :I'm a complete novice to python and Django.I have tried several solutions I found on stack overflow, but I still get the same issue. I've tried querying from shell and it works well, but not on my code.I've installed `pylint` usingpip install pylint-djangoI have also changed the Linter settings on Settings > User Settings > Python from `pyLint` to `pylint_django` and also to `flake8`, but no positive results.I still get the message "Class Courses has no 'objects' member pylint(no-member)"These are my codes from models.py:class Courses(models.Model):course_title = models.CharField(max_length=200)course_image = models.ImageField(upload_to='course_images/')course_duration = models.TimeField()def __str__(self):return self.course_titleThe views.py looks like this:from django.shortcuts import renderfrom django.http import HttpResponsefrom .models import Coursesdef homepage(request):cos = Courses.objects.all()context={ 'courses': cos }return render(request, "main/home.html", context)I need help. I'm completely stuck.Same for me with a code that comes from a site of initiation to django. In fact it seems that writing Courses.objects.all() is not correct. According to the django doc, you have to add a Manager attribute . I don't really understand why, but it works.In:class Courses(models.Model):you add :trick = models.ManagerThen in def homepage(request): you addcos= Courses.trick.all()Your error should disappear as it did for my code.Sorry if my point is not correct but I used an automatic translator to answer you.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6c92eb57-f5c3-4889-b41c-34d8f0ff3123%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB5F1iVEnj1uoskfanBrMq9MWziUer00NXrbVBuUQX7Wyfxf8w%40mail.gmail.com.
No comments:
Post a Comment