fix get_color() on ModelInstanceWrapper
This commit is contained in:
parent
8fef2a81a9
commit
edfb083c61
7 changed files with 33 additions and 30 deletions
|
@ -112,11 +112,13 @@ class Location(LocationSlug, EditorFormMixin, models.Model):
|
|||
return self._meta.verbose_name + ' ' + self.slug
|
||||
return super().title
|
||||
|
||||
def get_color(self):
|
||||
def get_color(self, instance=None):
|
||||
if self.color:
|
||||
return self.color
|
||||
# dont filter in the query here so prefetch_related works
|
||||
groups = [group for group in self.groups.all() if group.color is not None]
|
||||
if instance is None:
|
||||
instance = self
|
||||
groups = [group for group in instance.groups.all() if group.color is not None]
|
||||
if not groups:
|
||||
return None
|
||||
for group in groups:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue