##// END OF EJS Templates
Properly handle tag without aliases (though don't know how this can happen)
neko259 -
r2033:77184386 default
parent child Browse files
Show More
@@ -89,7 +89,17 b' class Tag(models.Model, Viewable):'
89 89 blank=True, related_name='children')
90 90
91 91 def get_name(self):
92 return self.aliases.get(locale=DEFAULT_LOCALE).name
92 try:
93 alias = self.aliases.get(locale=DEFAULT_LOCALE)
94 except TagAlias.DoesNotExist:
95 alias = self.aliases.first()
96
97 if alias:
98 return alias.name
99 else:
100 # This is an extremely bad situation, somehow we have a tag without
101 # any alias
102 return 'BROKEN #{}'.format(self.id)
93 103
94 104 def __str__(self):
95 105 return self.get_name()
General Comments 0
You need to be logged in to leave comments. Login now