Compare commits
No commits in common. "3d76637d846893e95be27195c383c356107b36a8" and "47cb55ab924388b8c9bea63ff27144434e291d9d" have entirely different histories.
3d76637d84
...
47cb55ab92
@ -9,14 +9,7 @@ class AnalyticsMiddleware:
|
|||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
|
||||||
def __call__(self, request):
|
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
|
# LOG 1: Check if Middleware is even being triggered
|
||||||
print(f"DEBUG: Middleware triggered for IP: {ip}")
|
print(f"DEBUG: Middleware triggered for IP: {ip}")
|
||||||
|
|||||||
@ -5,9 +5,14 @@ from .models import VisitorLog
|
|||||||
def log_visitor_location(ip_address):
|
def log_visitor_location(ip_address):
|
||||||
# if ip_address in ['127.0.0.1', 'localhost']:
|
# if ip_address in ['127.0.0.1', 'localhost']:
|
||||||
# return
|
# return
|
||||||
if ip_address.startswith(('127.', '10.')):
|
if ip_address.startswith(('127.', '192.168.', '10.', '172.16.')):
|
||||||
|
VisitorLog.objects.create(
|
||||||
print(f"DEBUG: Logged Skipped local IP {ip_address}")
|
ip_address=ip_address,
|
||||||
|
country="Local Network",
|
||||||
|
city="Development Machine",
|
||||||
|
region="Home"
|
||||||
|
)
|
||||||
|
print(f"DEBUG: Logged local IP {ip_address}")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -151,7 +151,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'Asia/Riyadh'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user