Files
django-core-base/apps/backend_admin/models.py
minguezsanzjuanjose 9dd97b34f2
All checks were successful
DEPLOY_MULTI_BRACH/pipeline/head This commit looks good
fix
2026-04-14 01:00:37 +02:00

25 lines
1.1 KiB
Python

from django.db import models
from django.utils import timezone
class Log(models.Model):
# Usamos BigAutoField para el BIGINT id de tu tabla
id = models.BigAutoField(primary_key=True)
user_id = models.IntegerField(default=0)
user = models.CharField(max_length=255, default='anonimo')
app_id = models.IntegerField(default=0)
# GenericIPAddressField para el tipo INET de Postgres
remote_address = models.GenericIPAddressField(null=True, blank=True)
request = models.JSONField(null=True, blank=True) # Para JSONB
response = models.JSONField(null=True, blank=True) # Para JSONB
status_code = models.CharField(max_length=10, default='0')
path = models.CharField(max_length=255)
method = models.CharField(max_length=10)
createdAt = models.DateTimeField(default=timezone.now)
updatedAt = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'audit_logs'
managed = False # Al estar la tabla ya creada, Django no intentará modificarla
def __str__(self):
return f"{self.method} {self.path} ({self.status_code})"