Coverage for actions/models.py: 93.33%
15 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-13 17:07 -0700
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-13 17:07 -0700
1from django.contrib.contenttypes.fields import GenericForeignKey
2from django.contrib.contenttypes.models import ContentType
3from django.db import models
6class Action(models.Model):
7 user = models.ForeignKey(
8 "auth.User",
9 related_name="actions",
10 on_delete=models.CASCADE,
11 )
12 verb = models.CharField(max_length=255)
13 created = models.DateTimeField(auto_now_add=True)
14 target_ct = models.ForeignKey(
15 ContentType,
16 blank=True,
17 null=True,
18 related_name="target_obj",
19 on_delete=models.CASCADE,
20 )
21 target_id = models.PositiveIntegerField(null=True, blank=True)
22 target = GenericForeignKey("target_ct", "target_id")
24 class Meta:
25 indexes = [
26 models.Index(fields=["-created"]),
27 models.Index(fields=["target_ct", "target_id"]),
28 ]
29 ordering = ["-created"]
31 def __str__(self):
32 pass