DRF

18 views
Skip to first unread message

Soumen Khatua

unread,
Jan 9, 2020, 7:31:47 AM1/9/20
to django...@googlegroups.com
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

Mandeep Tondak

unread,
Jan 9, 2020, 9:10:45 AM1/9/20
to django...@googlegroups.com
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

--
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...@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

Soumen Khatua

unread,
Jan 9, 2020, 9:25:52 AM1/9/20
to django...@googlegroups.com
if i'm using serializers still i need to do that?


Mandeep Tondak

unread,
Jan 9, 2020, 9:49:42 AM1/9/20
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages