Thursday, January 9, 2020

Re: DRF

Hi,

You need to import json then you can do like this

import json
data_json = json.loads(request.body.decode('utf-8'))

* decode('utf-8')  if you are using python 3 

Thanks

On Thu, Jan 9, 2020 at 1:01 PM Soumen Khatua <soumenkhatua258@gmail.com> wrote:
Hi Folks,

If I'm sending data into json format like this:

{ "name":"soumen","password":"@sou123"}

but in my python class,If doing something like this:

type(request.data.get("name")  #<'class Dict'> 

How it is possible without using serializer,How I can do access json data diresctly?

I'm using Django rest Framework.


Thank you in advance

Regards,
Soumen

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYN%2B73BMfnoLa_aq0t4090iGDAdBAtKhu5qXyfZPZiYsA%40mail.gmail.com.


--
Warm Regard:-
Mandeep Kumar

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJri7ST%2Bk__NtTPC0pk%2BpwHm6s4Brr7JAPe1s_8qpM0R-kyVtA%40mail.gmail.com.

No comments:

Post a Comment