File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
from django .contrib import auth
2
2
from django .contrib .auth import get_user_model
3
+ from django .core .exceptions import ValidationError
3
4
from django .http import Http404
4
- from rest_framework . generics import get_object_or_404
5
+ from django . shortcuts import get_object_or_404 as _get_object_or_404
5
6
6
7
from rest_registration .exceptions import UserNotFound
7
8
from rest_registration .settings import registration_settings
8
9
9
10
_RAISE_EXCEPTION = object ()
10
11
11
12
13
+ def get_object_or_404 (queryset , * filter_args , ** filter_kwargs ):
14
+ """
15
+ Same as Django's standard shortcut, but make sure to also raise 404
16
+ if the filter_kwargs don't match the required types.
17
+
18
+ This function was copied from rest_framework.generics because of issue #36.
19
+ """
20
+ try :
21
+ return _get_object_or_404 (queryset , * filter_args , ** filter_kwargs )
22
+ except (TypeError , ValueError , ValidationError ):
23
+ raise Http404
24
+
25
+
12
26
def get_user_setting (name ):
13
27
setting_name = 'USER_{name}' .format (name = name )
14
28
user_class = get_user_model ()
You can’t perform that action at this time.
0 commit comments