diff --git a/uhepp_org/uhepp_vault/models.py b/uhepp_org/uhepp_vault/models.py index 7c78ba3c8fff19a3ec4b46ae8ef7fd2b2943819e..29710e31494e594754a868f4ff6a946895fc8187 100644 --- a/uhepp_org/uhepp_vault/models.py +++ b/uhepp_org/uhepp_vault/models.py @@ -54,7 +54,7 @@ class Plot(models.Model): uhepp = models.JSONField() ui_view_count = models.IntegerField(default=0) api_view_count = models.IntegerField(default=0) - title = models.TextField(null=True, blank=True) + title = models.CharField(max_length=255, null=True, blank=True) collection = models.ForeignKey( Collection, @@ -80,6 +80,12 @@ class Plot(models.Model): ui_view_count=F('ui_view_count') + 1 ) + def save(self, *args, **kwds): + if self.title is None: + self.title = str(self) + + return super().save(*args, **kwds) + def __str__(self): if self.title: return self.title