use python repr/str for models

This commit is contained in:
sinavir 2023-02-16 19:10:23 +01:00
parent f03c371255
commit cd6169d0b3
2 changed files with 10 additions and 1 deletions

View file

@ -6,5 +6,8 @@ class Agent(models.Model):
name = models.CharField(max_length=255)
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
def __str__(self):
def __repr__(self):
return f"Agent_{self.name}"
def __str__(self):
return self.name

View file

@ -14,6 +14,9 @@ class BudgetLine(models.Model):
title = models.CharField(max_length=255)
def __str__(self):
return f"{self.title}"
def __repr__(self):
return f"BudgetLine_{self.title}_{self.amount}"
@ -25,4 +28,7 @@ class BudgetGroup(models.Model):
return sum(i.amount for i in self.budgetline_set.all())
def __str__(self):
return f"{self.name}"
def __repr__(self):
return f"BudgetGroup_{self.name}"