Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions cache_toolbox/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ def get_instance(model, instance_or_pk, timeout=None, using=None):
if field.primary_key:
continue

if field.get_internal_type() == 'FileField':
# Avoid problems with serializing FileFields
# by only serializing the file name
file = getattr(instance, field.attname)
data[field.attname] = file.name
else:
data[field.attname] = getattr(instance, field.attname)
# Serialise the instance using the Field's own serialisation routines.
data[field.attname] = field.value_to_string(instance)

if timeout is None:
timeout = app_settings.CACHE_TOOLBOX_DEFAULT_TIMEOUT
Expand All @@ -96,6 +91,6 @@ def instance_key(model, instance_or_pk):

return '%s.%s:%d' % (
model._meta.app_label,
model._meta.module_name,
model._meta.model_name,
getattr(instance_or_pk, 'pk', instance_or_pk),
)