Skip to content

Commit f0846c4

Browse files
committed
Exclude superusers from visit tracking middleware
- Modify visit tracking to skip superuser accounts - Improve error handling with explicit Exception catch - Prevent visit counter updates for admin/superuser accounts
1 parent e52689e commit f0846c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

blt/middleware/user_visit_tracking.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ def __init__(self, get_response):
33
self.get_response = get_response
44

55
def __call__(self, request):
6-
# update visit counter for authenticated users
7-
if request.user.is_authenticated:
6+
# update visit counter for authenticated users who are not superusers
7+
if request.user.is_authenticated and not request.user.is_superuser:
88
try:
99
profile = request.user.userprofile
1010
profile.update_visit_counter()
11-
except:
11+
except Exception:
1212
pass
1313

1414
response = self.get_response(request)

0 commit comments

Comments
 (0)