You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have this model called Palette and I'm using Django 2.2 latest patch, Django Cacheops 4.2
and once a week I have this exception breaking my API:
KeyError: 'palette'
File "django/db/models/fields/related_descriptors.py", line 164, in get
rel_obj = self.field.get_cached_value(instance)
File "django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
Palette.DoesNotExist: Palette matching query does not exist.
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "rest_framework/viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "palettes/views.py", line 190, in list
return super(PaletteViewSet, self).list(request, *args, **kwargs)
File "rest_framework/mixins.py", line 43, in list
return self.get_paginated_response(serializer.data)
File "rest_framework/serializers.py", line 760, in data
ret = super().data
File "rest_framework/serializers.py", line 260, in data
self._data = self.to_representation(self.instance)
File "rest_framework/serializers.py", line 678, in to_representation
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 678, in
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 529, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "rest_framework/fields.py", line 1905, in to_representation
return method(value)
File "palettes/serializers.py", line 367, in get_colors
return ColorsUsedInPaletteSerializer(qs, many=True, context=self.context).data[:5]
File "rest_framework/serializers.py", line 760, in data
ret = super().data
File "rest_framework/serializers.py", line 260, in data
self._data = self.to_representation(self.instance)
File "palettes/serializers.py", line 76, in to_representation
return super(PaletteItemListSerializer, self).to_representation(data)
File "rest_framework/serializers.py", line 678, in to_representation
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 678, in
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 529, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "rest_framework/fields.py", line 1905, in to_representation
return method(value)
File "cacheops/query.py", line 115, in wrapper
cache_key = prefix + 'as:' + key_func(func, args, kwargs, key_extra)
File "cacheops/utils.py", line 92, in func_cache_key
return md5hex(json.dumps(factors, sort_keys=True, default=obj_key))
File "init.py", line 238, in dumps
**kw).encode(obj)
File "json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "cacheops/utils.py", line 85, in obj_key
return str(obj)
File "rest_framework/serializers.py", line 537, in repr
return representation.serializer_repr(self, indent=1)
File "rest_framework/utils/representation.py", line 71, in serializer_repr
ret = field_repr(serializer, force_many) + ':'
File "rest_framework/utils/representation.py", line 54, in field_repr
arg_string = ', '.join([smart_repr(val) for val in field._args])
File "rest_framework/utils/representation.py", line 54, in
arg_string = ', '.join([smart_repr(val) for val in field._args])
File "rest_framework/utils/representation.py", line 33, in smart_repr
value = repr(value)
File "django/db/models/query.py", line 253, in repr
return '<%s %r>' % (self.class.name, data)
File "django/db/models/base.py", line 519, in repr
return '<%s: %s>' % (self.class.name, self)
File "palettes/models.py", line 140, in str
return f'{self.color} in {self.palette}'
File "django/db/models/fields/related_descriptors.py", line 178, in get
rel_obj = self.get_object(instance)
File "django/db/models/fields/related_descriptors.py", line 145, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "cacheops/query.py", line 359, in get
return qs._no_monkey.get(qs, *args, **kwargs)
File "django/db/models/query.py", line 408, in get
self.model._meta.object_name
And when I apply invalidate_model on Palette model, the issue is fixed.
I would deeply appreciate any help on this.
The text was updated successfully, but these errors were encountered:
Hi People,
I have this model called
Palette
and I'm using Django 2.2 latest patch, Django Cacheops 4.2and once a week I have this exception breaking my API:
KeyError: 'palette'
File "django/db/models/fields/related_descriptors.py", line 164, in get
rel_obj = self.field.get_cached_value(instance)
File "django/db/models/fields/mixins.py", line 13, in get_cached_value
return instance._state.fields_cache[cache_name]
Palette.DoesNotExist: Palette matching query does not exist.
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "rest_framework/viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "rest_framework/views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "rest_framework/views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "rest_framework/views.py", line 476, in raise_uncaught_exception
raise exc
File "rest_framework/views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "palettes/views.py", line 190, in list
return super(PaletteViewSet, self).list(request, *args, **kwargs)
File "rest_framework/mixins.py", line 43, in list
return self.get_paginated_response(serializer.data)
File "rest_framework/serializers.py", line 760, in data
ret = super().data
File "rest_framework/serializers.py", line 260, in data
self._data = self.to_representation(self.instance)
File "rest_framework/serializers.py", line 678, in to_representation
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 678, in
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 529, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "rest_framework/fields.py", line 1905, in to_representation
return method(value)
File "palettes/serializers.py", line 367, in get_colors
return ColorsUsedInPaletteSerializer(qs, many=True, context=self.context).data[:5]
File "rest_framework/serializers.py", line 760, in data
ret = super().data
File "rest_framework/serializers.py", line 260, in data
self._data = self.to_representation(self.instance)
File "palettes/serializers.py", line 76, in to_representation
return super(PaletteItemListSerializer, self).to_representation(data)
File "rest_framework/serializers.py", line 678, in to_representation
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 678, in
self.child.to_representation(item) for item in iterable
File "rest_framework/serializers.py", line 529, in to_representation
ret[field.field_name] = field.to_representation(attribute)
File "rest_framework/fields.py", line 1905, in to_representation
return method(value)
File "cacheops/query.py", line 115, in wrapper
cache_key = prefix + 'as:' + key_func(func, args, kwargs, key_extra)
File "cacheops/utils.py", line 92, in func_cache_key
return md5hex(json.dumps(factors, sort_keys=True, default=obj_key))
File "init.py", line 238, in dumps
**kw).encode(obj)
File "json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "cacheops/utils.py", line 85, in obj_key
return str(obj)
File "rest_framework/serializers.py", line 537, in repr
return representation.serializer_repr(self, indent=1)
File "rest_framework/utils/representation.py", line 71, in serializer_repr
ret = field_repr(serializer, force_many) + ':'
File "rest_framework/utils/representation.py", line 54, in field_repr
arg_string = ', '.join([smart_repr(val) for val in field._args])
File "rest_framework/utils/representation.py", line 54, in
arg_string = ', '.join([smart_repr(val) for val in field._args])
File "rest_framework/utils/representation.py", line 33, in smart_repr
value = repr(value)
File "django/db/models/query.py", line 253, in repr
return '<%s %r>' % (self.class.name, data)
File "django/db/models/base.py", line 519, in repr
return '<%s: %s>' % (self.class.name, self)
File "palettes/models.py", line 140, in str
return f'{self.color} in {self.palette}'
File "django/db/models/fields/related_descriptors.py", line 178, in get
rel_obj = self.get_object(instance)
File "django/db/models/fields/related_descriptors.py", line 145, in get_object
return qs.get(self.field.get_reverse_related_filter(instance))
File "cacheops/query.py", line 359, in get
return qs._no_monkey.get(qs, *args, **kwargs)
File "django/db/models/query.py", line 408, in get
self.model._meta.object_name
And when I apply
invalidate_model
onPalette
model, the issue is fixed.I would deeply appreciate any help on this.
The text was updated successfully, but these errors were encountered: