[Answer]-How to write Python classes that wrap Django ORM without circular references (for memcaching)?

1đź‘Ť

You can import inside functions/methods:

class Person(models.Model):
    ...
    @property
    def things(self):
        from myapp.cachedthings import CachedThing
        ...

But I think that custom ModelManager is a better option for such task. Google for “django cache model manager” – there is a lot of tips and apps created for this purpose.

👤catavaran

Leave a comment