datatracker/patch/tastypie-django22-fielderror-response.patch
2023-05-12 17:25:20 -03:00

33 lines
1.4 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
@@ -12,7 +12,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
from django.urls.conf import re_path
from tastypie.utils.timezone import make_naive_utc
@@ -2198,6 +2198,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
@@ -124,6 +124,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):
"""