Skip to content

Commit

Permalink
Add fix for failing queryset filters in nested routes
Browse files Browse the repository at this point in the history
If a route such as /users/NOT_AN_INTEGER/settings would be
requested and the /users endpoint expects an integer as the second
part of the url then this request would throw a internal server error.

This is a temp fix and a proper solution should be found. Discussion
about this can be found on Github:
chibisov#86
chibisov#63
chibisov#50
  • Loading branch information
Frank Wickström committed Jun 2, 2015
1 parent 67e8c46 commit 5155326
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion rest_framework_extensions/mixins.py
Expand Up @@ -4,6 +4,7 @@
from rest_framework_extensions.utils import get_rest_framework_features
from rest_framework_extensions.bulk_operations.mixins import ListDestroyModelMixin, ListUpdateModelMixin
from rest_framework_extensions.settings import extensions_api_settings
from django.http import Http404


class DetailSerializerMixin(object):
Expand Down Expand Up @@ -63,7 +64,10 @@ def get_queryset(self):
def filter_queryset_by_parents_lookups(self, queryset):
parents_query_dict = self.get_parents_query_dict()
if parents_query_dict:
return queryset.filter(**parents_query_dict)
try:
return queryset.filter(**parents_query_dict)
except ValueError:
raise Http404
else:
return queryset

Expand Down

0 comments on commit 5155326

Please sign in to comment.