Compare commits

...

2 Commits

Author SHA1 Message Date
3d76637d84 local ip address removed from storing 2025-12-29 14:48:44 +03:00
b5b5be3007 timezone added 2025-12-29 14:08:24 +03:00
3 changed files with 12 additions and 10 deletions

View File

@ -9,7 +9,14 @@ class AnalyticsMiddleware:
self.get_response = get_response
def __call__(self, request):
ip = request.META.get('REMOTE_ADDR')
# ip = request.META.get('REMOTE_ADDR')
# 1. Get the real IP
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
# Get the first IP in the list (the original client)
ip = x_forwarded_for.split(',')[0].strip()
else:
ip = request.META.get('REMOTE_ADDR')
# LOG 1: Check if Middleware is even being triggered
print(f"DEBUG: Middleware triggered for IP: {ip}")

View File

@ -5,14 +5,9 @@ from .models import VisitorLog
def log_visitor_location(ip_address):
# if ip_address in ['127.0.0.1', 'localhost']:
# return
if ip_address.startswith(('127.', '192.168.', '10.', '172.16.')):
VisitorLog.objects.create(
ip_address=ip_address,
country="Local Network",
city="Development Machine",
region="Home"
)
print(f"DEBUG: Logged local IP {ip_address}")
if ip_address.startswith(('127.', '10.')):
print(f"DEBUG: Logged Skipped local IP {ip_address}")
return
try:

View File

@ -151,7 +151,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Riyadh'
USE_I18N = True