From cd6169d0b3fd7b9abc2a3fc349af7f9ba2fa1d05 Mon Sep 17 00:00:00 2001 From: sinavir Date: Thu, 16 Feb 2023 19:10:23 +0100 Subject: [PATCH] use python repr/str for models --- hackens_orga/agent/models.py | 5 ++++- hackens_orga/budget/models.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hackens_orga/agent/models.py b/hackens_orga/agent/models.py index 1bb8c1a..0ef5b6e 100644 --- a/hackens_orga/agent/models.py +++ b/hackens_orga/agent/models.py @@ -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 diff --git a/hackens_orga/budget/models.py b/hackens_orga/budget/models.py index e2ba0f2..a30ef4a 100644 --- a/hackens_orga/budget/models.py +++ b/hackens_orga/budget/models.py @@ -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}"