mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
support args on get_object_or_404
This commit is contained in:
parent
181e4fddd0
commit
7231653915
|
@ -14,13 +14,13 @@ from rest_framework.settings import api_settings
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
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
|
Same as Django's standard shortcut, but make sure to raise 404
|
||||||
if the filter_kwargs don't match the required types.
|
if the filter_kwargs don't match the required types.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return _get_object_or_404(queryset, **filter_kwargs)
|
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user