mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-27 03:54:01 +03:00
Merge pull request #1153 from hcliff/master
support args on get_object_or_404
This commit is contained in:
commit
0d98622c21
|
@ -25,13 +25,13 @@ def strict_positive_int(integer_string, cutoff=None):
|
|||
ret = min(ret, cutoff)
|
||||
return ret
|
||||
|
||||
def get_object_or_404(queryset, **filter_kwargs):
|
||||
def get_object_or_404(queryset, *filter_args, **filter_kwargs):
|
||||
"""
|
||||
Same as Django's standard shortcut, but make sure to raise 404
|
||||
if the filter_kwargs don't match the required types.
|
||||
"""
|
||||
try:
|
||||
return _get_object_or_404(queryset, **filter_kwargs)
|
||||
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
|
||||
except (TypeError, ValueError):
|
||||
raise Http404
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user