Commits

Luke Plant  committed 495bd73

Fixed bug with ManyToMany erroring with invalid query param

  • Participants
  • Parent commits 8656fb9

Comments (0)

Files changed (2)

File django_easyfilters/filters.py

                              None, # Don't need count for removing
                              self.build_params(remove=[choice]),
                              FILTER_REMOVE)
-                for choice in chosen]
+                for choice in chosen if choice in obj_dict]
 
 
 class DrillDownMixin(object):

File django_easyfilters/tests/filterset.py

                           (unicode(anne), FILTER_REMOVE),
                           (unicode(charlotte), FILTER_ADD)])
 
+    def test_manytomany_filter_invalid_query(self):
+        self.do_invalid_query_param_test(lambda params:
+                                             ManyToManyFilter('authors', Book, params),
+                                         MultiValueDict({'authors':['xxx']}))
+        self.do_missing_related_object_test(lambda params:
+                                                ManyToManyFilter('authors', Book, params),
+                                            MultiValueDict({'authors':['10000']}))
+
     def test_datetime_filter_multiple_year_choices(self):
         """
         Tests that DateTimeFilter can produce choices spanning a set of years