Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

AttributeError: This QueryDict instance is immutable django

#views.py
from rest_framework import generics


class Login(generics.CreateAPIView):
    serializer_class = MySerializerClass
    def create(self, request, *args, **kwargs):
        request.data._mutable = True
        request.data['username'] = "example@mail.com"
        request.data._mutable = False

#serializes.py
from rest_framework import serializers


class MySerializerClass(serializers.Serializer):
    username = serializers.CharField(required=False)
    password = serializers.CharField(required=False)
    class Meta:
        fields = ('username', 'password')
Comment

PREVIOUS NEXT
Code Example
Python :: pandas create column from another column 
Python :: add rows to dataframe pandas 
Python :: python httpserver 
Python :: check palindrome in python using recursion 
Python :: selenium quit browser python 
Python :: python program to find n prime numbers 
Python :: the day before today python datetime 
Python :: get text from url python last slash 
Python :: 1 day ago python datetime 
Python :: matplotlib set size 
Python :: p-norm of a vector python 
Python :: minimum and max value in all columns pandas 
Python :: download youtube video in python 
Python :: python write a list to a file line by line 
Python :: python show image cv2 
Python :: run code with different verions of python 
Python :: no module named base45 windows 
Python :: pythoni me numra 
Python :: is prime python 
Python :: how to create a tkinter window 
Python :: convert 2 columns to dictionary pandas 
Python :: making a python code without python 
Python :: admin.tabularinline access values via a foreign key 
Python :: python list comprehension index, value 
Python :: python export console output to file 
Python :: python seaborn heatmap decrease annot size 
Python :: orderd dictionary pop vs del 
Python :: how to limit a long text in djagno 
Python :: dataframe plot distribution of dates 
Python :: python date + days 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =