Add str method to attachment

This commit is contained in:
Gabriel Augendre 2020-08-27 22:09:18 +02:00
parent 57c1fe1ce8
commit 945768a3e6
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4

View file

@ -14,6 +14,9 @@ class Attachment(models.Model):
original_file = models.FileField() original_file = models.FileField()
processed_file = models.FileField(blank=True, null=True) processed_file = models.FileField(blank=True, null=True)
def __str__(self):
return f"{self.description} ({self.original_file.name})"
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.processed_file: if self.processed_file:
return super().save(*args, **kwargs) return super().save(*args, **kwargs)