replaced StatsLog.model with a generic foreign key
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from django.contrib.gis.db import models
|
from django.contrib.gis.db import models
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
@@ -7,7 +8,14 @@ User = get_user_model()
|
|||||||
|
|
||||||
class StatsLog(models.Model):
|
class StatsLog(models.Model):
|
||||||
|
|
||||||
model = models.ForeignKey(ContentType, on_delete=models.DO_NOTHING, null=True)
|
action_object_content_type = models.ForeignKey(
|
||||||
|
ContentType, blank=True,
|
||||||
|
null=True,
|
||||||
|
related_name='statslogs',
|
||||||
|
on_delete=models.CASCADE
|
||||||
|
)
|
||||||
|
action_object_object_id = models.CharField(max_length=255, blank=True, null=True)
|
||||||
|
action_object = GenericForeignKey('action_object_content_type', 'action_object_object_id')
|
||||||
user = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True)
|
user = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True)
|
||||||
anonymous = models.BooleanField('Usuario no registrado', null=True)
|
anonymous = models.BooleanField('Usuario no registrado', null=True)
|
||||||
ip_address = models.GenericIPAddressField('IP usuario', null=True, blank=True)
|
ip_address = models.GenericIPAddressField('IP usuario', null=True, blank=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user