Skip to content

Commit

Permalink
add additional field in model hit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ione03 committed Jun 2, 2021
1 parent cf66eb3 commit 9457e89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions hitcount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion hitcount/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9457e89

Please sign in to comment.