diff --git a/hitcount/models.py b/hitcount/models.py index faa9c3e..55228ee 100644 --- a/hitcount/models.py +++ b/hitcount/models.py @@ -124,6 +124,7 @@ class Hit(models.Model): ip = models.CharField(max_length=40, editable=False, db_index=True) session = models.CharField(max_length=40, editable=False, db_index=True) user_agent = models.CharField(max_length=255, editable=False) + domain = models.CharField(max_length=255, editable=False) user = models.ForeignKey(AUTH_USER_MODEL, null=True, editable=False, on_delete=models.CASCADE) hitcount = models.ForeignKey(MODEL_HITCOUNT, editable=False, on_delete=models.CASCADE) diff --git a/hitcount/views.py b/hitcount/views.py index fd1491a..e8b45b9 100644 --- a/hitcount/views.py +++ b/hitcount/views.py @@ -78,7 +78,7 @@ def hit_count(self, request, hitcount): False, 'Not counted: hits per IP address limit reached') # create a generic Hit object with request data - hit = Hit(session=session_key, hitcount=hitcount, ip=get_ip(request), + hit = Hit(session=session_key, hitcount=hitcount, ip=get_ip(request), domain=request.get_host(), user_agent=request.META.get('HTTP_USER_AGENT', '')[:255],) # first, use a user's authentication to see if they made an earlier hit