File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -46,19 +46,18 @@ A classic example of this would be to attach ``Profile`` data
46
46
to ``User `` object so calling ``request.user.profile `` does not incur a
47
47
database hit. Here's how we can implement it.
48
48
49
- `` ` python
49
+ .. code-block :: python
50
50
51
- def attach_profile(user, request):
52
- try:
53
- user.get_profile()
54
- # Handle exception for user with no profile and AnonymousUser
55
- except (Profile.DoesNotExist, AttributeError):
56
- pass
51
+ def attach_profile (user , request ):
52
+ try :
53
+ user.get_profile()
54
+ # Handle exception for user with no profile and AnonymousUser
55
+ except (Profile.DoesNotExist, AttributeError ):
56
+ pass
57
57
58
58
59
- # In settings.py:
60
- CACHED_AUTH_PREPROCESSOR = 'path.to.module.attach_profile'
61
- ` ``
59
+ # In settings.py:
60
+ CACHED_AUTH_PREPROCESSOR = ' path.to.module.attach_profile'
62
61
63
62
Running Tests
64
63
-------------
You can’t perform that action at this time.
0 commit comments