【发布时间】:2014-06-22 18:18:23
【问题描述】:
我目前在模型类上使用@cached_property,我想在保存时将其删除,以便在下次调用时重新填充。我该怎么做呢?
示例:
class Amodel():
#...model_fields....
@cached_property
def db_connection(self):
#get some thing in the db and cache here
instance = Amodel.objects.get(id=1)
variable = instance.db_connection
Amodel.objects.select_for_update().filter(id=1).update(#some variable)
#invalidate instance.db_connection
#new_variable = instance.db_connection
谢谢
【问题讨论】:
标签: python django django-models django-views