2👍
Make your own custom manager that inherits from GeoManager and returns a CachingQuerySet:
In myapp/manager.py:
from django.contrib.gis.db.models import GeoManager
from caching.base import CachingQuerySet
class MyModelManager(GeoManager):
"""
A custom manager for myapp models.
"""
def get_queryset(self):
return CachingQuerySet(self.model, using=self._db)
In myapp/models.py:
from django.contrib.gis.db import models
from caching.base import CachingMixin
from .manager import MyModelManager
class MyModel(CachingMixin, models.Model):
something = models.CharField()
objects = MyModelManager()
And you got yourself a cacheable model.
Source:stackexchange.com