Add __str__ to models
This commit is contained in:
parent
0b58580a00
commit
a0f4e5ae54
2 changed files with 40 additions and 13 deletions
|
@ -9,9 +9,15 @@ class Transaction(models.Model):
|
|||
value = models.DecimalField(max_digits=12, decimal_places=2)
|
||||
date = models.DateField()
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.date} {self.name}: {self.value}€"
|
||||
|
||||
|
||||
class Invoice(models.Model):
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
name = models.CharField(max_length=256)
|
||||
file = models.FileField(upload_to="invoices/")
|
||||
transaction = models.ForeignKey(Transaction, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}: {self.transaction}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue