20 lines
646 B
Python
20 lines
646 B
Python
from django.db import models
|
|
from core.models import BaseModel
|
|
|
|
|
|
class AccessLog(BaseModel):
|
|
"""Model to store access logs for user requests."""
|
|
class Meta:
|
|
verbose_name = "Access Log"
|
|
verbose_name_plural = "Access Logs"
|
|
ordering = ['-timestamp']
|
|
|
|
username = models.CharField(max_length=150)
|
|
method = models.CharField(max_length=10)
|
|
path = models.CharField(max_length=2048)
|
|
timestamp = models.DateTimeField(auto_now_add=True)
|
|
ip_address = models.GenericIPAddressField(null=True, blank=True)
|
|
|
|
def __str__(self):
|
|
return f'[{self.timestamp}] {self.username} {self.method} {self.path}'
|