Skip to content

Commit 23845f2

Browse files
Merge pull request #1673 from IFRCGo/fix/localunit-str-method
Add __str__ method to LocalUnit model
2 parents e199407 + 4b46c98 commit 23845f2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

local_units/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class LocalUnitType(models.Model):
1818
verbose_name=_('Name')
1919
)
2020

21+
def __str__(self):
22+
return f'{self.name} ({self.level})'
23+
2124

2225
class LocalUnit(models.Model):
2326
country = models.ForeignKey(
@@ -105,3 +108,8 @@ class LocalUnit(models.Model):
105108
verbose_name=_('Social link')
106109
)
107110
location = models.PointField()
111+
112+
def __str__(self):
113+
branch_name = self.local_branch_name or self.english_branch_name
114+
return f'{branch_name} ({self.country.name})'
115+

0 commit comments

Comments
 (0)