From 212faf0ceff9702d9c7d49cc6ab7cab228cdb778 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Tue, 8 Oct 2024 17:56:09 -0400
Subject: [PATCH] feat: add request to TimeslotViewset context

---
 program/views.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/program/views.py b/program/views.py
index 97ca0648..a47f5cb1 100644
--- a/program/views.py
+++ b/program/views.py
@@ -1332,7 +1332,12 @@ class APITimeSlotViewSet(
     def update(self, request, *args, **kwargs):
         show_pk = get_values(self.kwargs, "show_pk")
         timeslot = self.get_object()
-        serializer = TimeSlotSerializer(timeslot, data=request.data)
+        serializer = TimeSlotSerializer(
+            timeslot,
+            context={"request": request},  # the serializer needs the request in the context
+            data=request.data,
+        )
+
         if serializer.is_valid(raise_exception=True):
             serializer.save()
 
-- 
GitLab