fix au cas où Place n'existe pas avant migration
This commit is contained in:
parent
c6352091ea
commit
8119ea98cd
@ -182,6 +182,13 @@ class Place(models.Model):
|
|||||||
def match(self, event):
|
def match(self, event):
|
||||||
return event.location in self.aliases
|
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):
|
class Event(models.Model):
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class EventFilter(django_filters.FilterSet):
|
|||||||
|
|
||||||
city = django_filters.MultipleChoiceFilter(label="Filtrer par ville",
|
city = django_filters.MultipleChoiceFilter(label="Filtrer par ville",
|
||||||
field_name='exact_location__city',
|
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)
|
widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
||||||
status = django_filters.MultipleChoiceFilter(label="Filtrer par status",
|
status = django_filters.MultipleChoiceFilter(label="Filtrer par status",
|
||||||
|
Loading…
Reference in New Issue
Block a user