0

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?

YakovL
  • 7,557
  • 12
  • 62
  • 102

1 Answers1

0

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

Bidhan Majhi
  • 1,320
  • 1
  • 12
  • 25