Skip to content

Commit 49e913a

Browse files
committed
Add exception handler for AnonymousUser
1 parent 2ab6823 commit 49e913a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

authors.rst

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
Author:
22
* Selwin Ong
3+
4+
Contributors:
5+
* Gilang Chandrasa

cached_auth/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def get_cached_user(request):
4343
if profile_model:
4444
try:
4545
user.get_profile()
46-
except profile_model.DoesNotExist:
46+
# Handle exception for user with no profile and AnonymousUser
47+
except (profile_model.DoesNotExist, AttributeError):
4748
pass
4849
cache.set(key, user)
4950
request._cached_user = user

0 commit comments

Comments
 (0)