Skip to content

Commit

Permalink
add db constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Mar 12, 2024
1 parent e445f72 commit 5534d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions hawc/apps/udf/migrations/0003_modeludfcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ class Migration(migrations.Migration):
),
],
),
migrations.AlterUniqueTogether(
name="modeludfcontent",
unique_together={("model_binding", "object_id")},
),
]
8 changes: 4 additions & 4 deletions hawc/apps/udf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ class ModelUDFContent(models.Model):
)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField(null=True)
content_object = GenericForeignKey(
"content_type",
"object_id",
)
content_object = GenericForeignKey("content_type", "object_id")
content = models.JSONField(blank=True, default=dict)
created = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)

class Meta:
unique_together = (("model_binding", "object_id"),)

def get_content_as_list(self):
schema = dynamic_forms.Schema.parse_obj(self.model_binding.form.schema)

Expand Down

0 comments on commit 5534d61

Please sign in to comment.