Django Models objects cannot find declaration to go to

I have a simple django app. Inside the models.py folder i have:

class TestModel(models.Model):
    name = models.CharField(max_length=300)

    def get_all(self):
        all = TestModel.objects.all()
        return all

Even though I have instances of TestModel in my database (PostgreSQL), the function get_all returns None. PyCharm helped me in narrowing down the problem by marking objects and telling me that it Cannot find a declaration to go to. If I create the project with PyCharm Professional through the UI, this problem does not occur. As soon as I open the application through PyCharm Community, the problem appears and does NOT go away by switching back to Professional.

Django version - 3.2.9 and 4.0.0 tested

Questions:

  1. How to make the Django recognize objects by using PyCharm Community?
  2. What is the cause for this strange behaviour?
Back to Top