File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -527,6 +527,11 @@ def _filter_queryset(
527
527
raise ValidationError (
528
528
dict (e ) if hasattr (e , 'error_dict' ) else list (e )
529
529
)
530
+ except Exception as e :
531
+ # Some other Django error in parsing the filter. Very likely
532
+ # a bad query, so throw a ValidationError.
533
+ err_msg = getattr (e , 'message' , '' )
534
+ raise ValidationError (err_msg )
530
535
531
536
# A serializer can have this optional function
532
537
# to dynamically apply additional filters on
Original file line number Diff line number Diff line change @@ -1491,3 +1491,15 @@ def test_immutable_field(self):
1491
1491
# ... and it should not have changed:
1492
1492
self .assertEqual (data ['cat' ]['parent' ], parent_id )
1493
1493
self .assertEqual (data ['cat' ]['name' ], kitten_name )
1494
+
1495
+
1496
+ class TestFilters (APITestCase ):
1497
+
1498
+ """
1499
+ Tests for filters.
1500
+ """
1501
+
1502
+ def testUnparseableInt (self ):
1503
+ url = '/users/?filter{pk}=123x'
1504
+ response = self .client .get (url )
1505
+ self .assertEqual (400 , response .status_code )
You can’t perform that action at this time.
0 commit comments