Unresolved reference 'objects' attribute for class 'Foo' in PyCharm

Why am I seeing this warning for a class that is a subclass of models. Mod (Foo is defined as class Foo (models.Model))? This is where I use Foo.objects.filter (...).

Answering a query in more detail with a simplified example:

# ------ models.py ---------
from django.db import models

class Foo(models.Model):
    pass

# ------ views.py ---------
from models import Foo

inquiry = Foo.objects.filter(...)  # PyCharm gives warning for objects here
    ...

      

PyCharm does not give any warnings for import statements in any file.

+3


source to share


1 answer


Is your version or the professional version of pycharm. If your pycharm is a community it might need a pluggin to support django. If your pycharm is professional please be sure. Preferences -> Languages โ€‹โ€‹& Frameworks ---> Django -> Enable Django Support. see also img in enter image description here



+6


source







All Articles