diff --git a/api/dashboard/task/dash_task_view.py b/api/dashboard/task/dash_task_view.py index 7a953efc..670b2051 100644 --- a/api/dashboard/task/dash_task_view.py +++ b/api/dashboard/task/dash_task_view.py @@ -100,8 +100,11 @@ def get(self, request): def post(self, request): # create user_id = JWTUtils.fetch_user_id(request) - request.data["created_by"] = request.data["updated_by"] = user_id - serializer = TaskModifySerializer(data=request.data) + mutable_data = request.data.copy() # Create a mutable copy of request.data + mutable_data["created_by"] = user_id + mutable_data["updated_by"] = user_id + + serializer = TaskModifySerializer(data=mutable_data) if not serializer.is_valid(): return CustomResponse( @@ -140,13 +143,14 @@ def get(self, request, task_id): def put(self, request, task_id): # edit user_id = JWTUtils.fetch_user_id(request) - request.data["updated_by"] = user_id + mutable_data = request.data.copy() # Create a mutable copy of request.data + mutable_data["updated_by"] = user_id task = TaskList.objects.get(pk=task_id) serializer = TaskModifySerializer( task, - data=request.data, + data=mutable_data, partial=True ) diff --git a/db/user.py b/db/user.py index 050fe7d5..8a512b4a 100644 --- a/db/user.py +++ b/db/user.py @@ -20,7 +20,7 @@ class User(models.Model): active = models.BooleanField(default=True) exist_in_guild = models.BooleanField(default=False) profile_pic = models.CharField(max_length=200, blank=True, null=True) - district = models.ForeignKey("District",on_delete=models.CASCADE, blank=True, null=True) + district = models.ForeignKey("District",on_delete=models.CASCADE, blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) class Meta: