From 344f79b091f30d25ad9818efee79a3107bb0b19e Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Tue, 12 Apr 2022 07:03:48 +0200 Subject: [PATCH] Added __str__ method to show up useful names in selectors --- container/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/container/models.py b/container/models.py index 59ff1f7..b259202 100644 --- a/container/models.py +++ b/container/models.py @@ -21,6 +21,9 @@ class ContainerType(models.Model): changed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_deleted_user), related_name='changed_container_types') + def __str__(self): + return self.named_id + ': ' + self.description + class Container(models.Model): named_id = models.CharField(max_length=40) @@ -33,3 +36,6 @@ class Container(models.Model): changed_ts = models.DateTimeField('datetime updated', auto_now=True) changed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_deleted_user), related_name='changed_container') + + def __str__(self): + return self.named_id + ' (' + self.container_type.named_id + '): ' + self.description