class django_dbcache_fields.decorators.dbcache(field, field_name=None, dirty_func=None, invalidated_by=None)

Decorate a class method on a Django Model to store the result of that method in the database.

__init__(field, field_name=None, dirty_func=None, invalidated_by=None)


  • field – Django Model Field instance to store the result.
  • field_name – The field name of the Field instance.
  • dirty_func – A function that takes 2 arguments (the Model instance and the field name) that should return True if the field value should be recalculated using the original method.
  • invalidated_by – A list of model names in the form {app_label}.{model name} that when updated, invalidate this field.

list of weak references to the object (if defined)