0
Django1.9緩存可以通過from django.core.cache import cache
訪問。 但是怎樣才能訪問模型緩存?在Django 1.9中訪問模型緩存
此代碼在以前的版本中工作。
from django.db.models.loading import cache
from django.db import models
def get_custom_car_model(car_model_definition):
""" Create a custom (dynamic) model class based on the given definition.
"""
# What's the name of your app?
_app_label = 'myapp'
# you need to come up with a unique table name
_db_table = 'dynamic_car_%d' % car_model_definition.pk
# you need to come up with a unique model name (used in model caching)
_model_name = "DynamicCar%d" % car_model_definition.pk
# Remove any exist model definition from Django's cache
try:
del cache.app_models[_app_label][_model_name.lower()]
except KeyError:
pass
...
現在該如何處理?我想刪除模型緩存
我收到錯誤
'LocMemCache' object has no attribute app_models
什麼是不工作的,現在? – Sayse