Skip to content
Snippets Groups Projects

Fix API detail views

Merged Benjamin Hättasch requested to merge fix-api into main
1 file
+ 5
0
Compare changes
  • Side-by-side
  • Inline
  • fd0b8982
    Fix API detail views · fd0b8982
    Benjamin Hättasch authored
    Previously, the event from the url was not parsed correctly for API endpoints for individual AKs, AKRooms, etc. This led to self.event being None and the queryset being empty, hence the AK, AKRoom etc. could not be found by the API. This fix makes sure, the event is loaded as part of the API initialization for all endpoints and methods.
+ 5
0
@@ -38,6 +38,11 @@ class EventSlugMixin:
self._load_event()
return super().create(request, *args, **kwargs)
def initial(self, request, *args, **kwargs):
if self.event is None:
self._load_event()
super().initial(request, *args, **kwargs)
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
# Add event to context (to make it accessible in templates)
Loading