from django.db import models


class ModelCaching(models.Model):
    pass

from django.db import models
from django.core.cache import cache

from .managers import CacheManager


ModelBase = type(models.Model)


class MetaCaching(ModelBase):
    def __new__(*args, **kwargs):
        new_class = ModelBase.__new__(*args, **kwargs)
        new_manager = CacheManager()
        new_manager.contribute_to_class(new_class, 'objects')
        new_class._default_manager = new_manager
        return new_class


Create MetaCaching, ModelBase for core cache
Create MetaCaching, ModelBase for core cache

  from django.db import models
+ from django.core.cache import cache
+ 
+ from .managers import CacheManager
  
  
+ ModelBase = type(models.Model)
- class ModelCaching(models.Model):
-     pass
  
+ 
+ class MetaCaching(ModelBase):
+     def __new__(*args, **kwargs):
+         new_class = ModelBase.__new__(*args, **kwargs)
+         new_manager = CacheManager()
+         new_manager.contribute_to_class(new_class, 'objects')
+         new_class._default_manager = new_manager
+         return new_class
+ 
+ 
Create MetaCaching, ModelBase for core cache
## Code Before:
from django.db import models


class ModelCaching(models.Model):
    pass

## Instruction:
Create MetaCaching, ModelBase for core cache
## Code After:
from django.db import models
from django.core.cache import cache

from .managers import CacheManager


ModelBase = type(models.Model)


class MetaCaching(ModelBase):
    def __new__(*args, **kwargs):
        new_class = ModelBase.__new__(*args, **kwargs)
        new_manager = CacheManager()
        new_manager.contribute_to_class(new_class, 'objects')
        new_class._default_manager = new_manager
        return new_class

