datatracker/patch/tastypie-django22-fielderror-response.patch
Henrik Levkowetz 5931b5d778 Added another tastypie patch
- Legacy-Id: 18411
2020-08-25 13:30:01 +00:00

33 lines
1.3 KiB
Diff

--- tastypie/resources.py.orig 2020-08-24 13:14:25.463166100 +0200
+++ tastypie/resources.py 2020-08-24 13:15:55.133759224 +0200
@@ -15,7 +15,7 @@
ObjectDoesNotExist, MultipleObjectsReturned, ValidationError, FieldDoesNotExist
)
from django.core.signals import got_request_exception
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, FieldError
from django.db.models.fields.related import ForeignKey
try:
from django.contrib.gis.db.models.fields import GeometryField
@@ -2207,6 +2207,8 @@
return self.authorized_read_list(objects, bundle)
except ValueError:
raise BadRequest("Invalid resource lookup data provided (mismatched type).")
+ except FieldError as e:
+ raise BadRequest("Invalid resource lookup: %s." % e)
def obj_get(self, bundle, **kwargs):
"""
--- tastypie/paginator.py.orig 2020-08-25 15:24:46.391588425 +0200
+++ tastypie/paginator.py 2020-08-25 15:24:53.591797122 +0200
@@ -128,6 +128,8 @@
except (AttributeError, TypeError):
# If it's not a QuerySet (or it's ilk), fallback to ``len``.
return len(self.objects)
+ except ValueError as e:
+ raise BadRequest("Invalid resource lookup: %s." % e)
def get_previous(self, limit, offset):
"""