Exemplo n.º 1
0
 def put(self, request):
     user = request.current_user
     settings = user.settings
     serializer = SettingsSerializer(settings, data=request.data)
     serializer.is_valid(raise_exception=True)
     updated_settings = serializer.save()
     return JsonResponse(SettingsSerializer(updated_settings).data)
Exemplo n.º 2
0
 def post(self, request):
     serializer = SettingsSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     settings = serializer.save()
     user = request.current_user
     user.settings = settings
     user.save()
     return JsonResponse(SettingsSerializer(settings).data)