0

I am trying to upgrade my Django 1.10 project from python 2.7 to python 3, and basically have issues with the following code snippet:

class QuerySetManager(models.Manager):
    def get_queryset(self):
        pass

    def __getattr__(self, attr, *args):
        return self.get_queryset()

If I comment out __getattr__ part from my code, everything works just fine. Otherwise, I end up with error:

django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet

Any ideas how to rewrite the code to run under python 3.x ?

Edgar Navasardyan
  • 4,261
  • 8
  • 58
  • 121
  • A quick google of "`django python 3 __getattr__`" led to the possibility that maybe you need to intercept just the attributes you're expecting and pass the rest on to the parent class with a `super` call? – glibdud Mar 08 '17 at 15:05
  • @Glibdud, I have around a year of experience in Django, and I am still uncomfortable with advanced topics like `super`-calls. Could you please provide minimum code snippet illustrating what you found (I posted question after two hours of googling) – Edgar Navasardyan Mar 08 '17 at 15:19
  • The first result of the above search led to [this answer](http://stackoverflow.com/a/4634274/789671). – glibdud Mar 08 '17 at 15:21

0 Answers0