when I set queryset=Post.objects.all()
the Post
class shows the error
"/d:/Programming/Python/Python_WorkPlace/New_django_project/posts/views.py", "message": "Class 'Post' has no 'objects' member"
Why so and how to fix this?
when I set queryset=Post.objects.all()
the Post
class shows the error
"/d:/Programming/Python/Python_WorkPlace/New_django_project/posts/views.py", "message": "Class 'Post' has no 'objects' member"
Why so and how to fix this?
Add this in your Post model,
class Post(models.Model):
#rest of your code
objects = models.Manager()
If you are not defining Manager instance, then 'objects' is added by default. In your case you are not getting objects by default. So you can add this manually.
Or if you are getting IDE warning only, in VS Code I guess, then install pylint, better described in this SO question
Refer Official Django Docs