[Chennaipy] Django doubt

Harshit Lingamneni harshitlingamneni at gmail.com
Wed Jul 22 07:47:59 CEST 2015


Hello,

There are many ways to do it.

1) If you are using postgresql, the TYPE of "type" can be set to json
(postgres dialects) and it can save arrays and dictionaries.

2) you can form an Array, and serialize it before dumping it in the
database, and jsonify the string you retrieved from the database and send
an array in response.

Corrections welcomed.

Thank You.


On Wed, Jul 22, 2015 at 1:23 AM, Maruti Nandan <nandanself at gmail.com> wrote:

> I am a newbie to django.I am designing a rest ful  api. In my response I
> am getting something like this
>
> { "id":"1" , " type ": "thin,tall,round", " "name": " foo" }
>
> But I want something like this
>
> { "id":"1" , " type ": ["thin","tall","round"] , " "name": " foo" }
>
> What model field type should I use to achieve this or any other approach.
> This may be very small query. But it will help me a lot
>
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20150722/5aa5f09b/attachment.html>


More information about the Chennaipy mailing list