fix au cas où Place n'existe pas avant migration

This commit is contained in:
Jean-Marie Favreau 2024-04-27 19:02:14 +02:00
parent c6352091ea
commit 8119ea98cd
2 changed files with 8 additions and 1 deletions

View File

@ -182,6 +182,13 @@ class Place(models.Model):
def match(self, event):
return event.location in self.aliases
def get_all_cities():
try:
tags = list([p["city"] for p in Place.objects.values("city").distinct().order_by("city")])
except:
tags = []
return tags
class Event(models.Model):

View File

@ -96,7 +96,7 @@ class EventFilter(django_filters.FilterSet):
city = django_filters.MultipleChoiceFilter(label="Filtrer par ville",
field_name='exact_location__city',
choices=[(p["city"], p["city"]) for p in Place.objects.values("city").distinct().order_by("city")],
choices=[(c, c) for c in Place.get_all_cities()],
widget=forms.CheckboxSelectMultiple)
status = django_filters.MultipleChoiceFilter(label="Filtrer par status",