diff options
| author | Bobby <[email protected]> | 2024-12-16 18:38:05 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-12-16 18:38:05 +0000 |
| commit | ea8f5e8517161c1bd52f61198138dfd2fc72f8e2 (patch) | |
| tree | 19dd955137c8c6bb9c1143bbced320737cd93b09 /middleware/userprofilemiddleware.py | |
| parent | 04788ddd83c5e80a09a468d07427f0e365db71d7 (diff) | |
| download | thatcomputerscientist-ea8f5e8517161c1bd52f61198138dfd2fc72f8e2.tar.xz thatcomputerscientist-ea8f5e8517161c1bd52f61198138dfd2fc72f8e2.zip | |
its all in a state of chaos, but it shall be working soon
Diffstat (limited to 'middleware/userprofilemiddleware.py')
| -rw-r--r-- | middleware/userprofilemiddleware.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/middleware/userprofilemiddleware.py b/middleware/userprofilemiddleware.py index 96a7997e..a7d2a281 100644 --- a/middleware/userprofilemiddleware.py +++ b/middleware/userprofilemiddleware.py @@ -6,7 +6,11 @@ from apps.blog.models import Post class UserProfileMiddleware(MiddlewareMixin): def process_request(self, request): if request.user.is_authenticated: - user_profile = UserProfile.objects.get(user=request.user) + try: + user_profile = UserProfile.objects.get(user=request.user) + except UserProfile.DoesNotExist: + user_profile = UserProfile(user=request.user) + user_profile.save() request.user.profile = user_profile request.user.profile.weblogs_created = Post.objects.filter( author=request.user |
