1👍
Using the APIView class is pretty much the same as using a regular View class, as usual, the incoming request is dispatched to an appropriate handler method such as .get() or .post()
If you doing a POST
request.You have to do
def post(self, request, format=None):
#rest of code
0👍
display_id = request.POST.get("textfield")
error with this line. you are missing self
. here it is returning NoneType. And change your method to post
def post(self, request, format=None):
display_id = self.request.POST.get("textfield")
try:
display_id = int(display_id)
except ValueError:
display_id = "here you give default value"
you got this error because you are trying to pass non-integer value as a string
- Making the first image select by default as featured from the modelformset_factory
- Django REST Serializer, show an exact value
Source:stackexchange.com