Django object to json

10 views
Skip to first unread message

Kamal Sharma

unread,
Jul 7, 2018, 7:42:48 AM7/7/18
to django...@googlegroups.com
hi,

I am facing a problem to get data from database in form of JSON.

data = model.objects.all()

now i have a big list in data and want to convert it into JSON.
how can i do it.

Thanks

Kamal Sharma
Message has been deleted

Mikhailo Keda

unread,
Jul 7, 2018, 8:18:56 AM7/7/18
to Django users

Bob Gailer

unread,
Jul 7, 2018, 8:21:15 AM7/7/18
to Django users

On Jul 7, 2018 7:42 AM, "Kamal Sharma" <kamal.co...@gmail.com> wrote:
>
> hi,
>
> I am facing a problem to get data from database in form of JSON.
>
> data = model.objects.all()
>
> now i have a big list in data and want to convert it into JSON.
> how can i do it.

import json
json_biglist = json.dumps(biglist)

Django may offer an alternative.

>
> Thanks
>
> Kamal Sharma
>
> --
> 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 post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHfh8PQmAZ5EB4ENunxjwdd%3DQcXDH-x8db9e6kP%2BtuY2Zr8vxw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages