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
Source:stackexchange.com