Re: Passing data from view to template

2009-12-11 Thread David
Cool. Thanks Shawn! On Dec 11, 7:32 pm, Shawn Milochik wrote: > You don't need to transfer this to JavaScript once it's in JSON, which is a > JavaScript object. > > If you're using AJAX, it's dead easy. > > #use this in your view > return HttpResponse(simplejson.dumps(employees), mimetype="appli

Re: Passing data from view to template

2009-12-11 Thread Shawn Milochik
You don't need to transfer this to JavaScript once it's in JSON, which is a JavaScript object. If you're using AJAX, it's dead easy. #use this in your view return HttpResponse(simplejson.dumps(employees), mimetype="application/json") Then, in your JavaScript, you can use JSON syntax to refer t

Re: Passing data from view to template

2009-12-11 Thread David
Hi Shawn, Thanks so much for your reply. Here is an example. I have a following dictionary in Python employees = { "accounting" : [ // accounting is an array in employees. { "firstName" : "John", // First element "lastN

Re: Passing data from view to template

2009-12-11 Thread Shawn Milochik
What kind of object are you trying to send? JSON pretty much looks identical to a Python dictionary, so if your object is a Python dictionary, list, or tuple you'll have no problem -- just convert the Python object using simplejson.dumps(). If this doesn't help much, please provide more detail

Passing data from view to template

2009-12-11 Thread David
hello, This is my first time to work in the Ajax filed. What I need to do is to pass an object from view to a javaScript function in template. The javaScript is Ajax. I have googled online and read some posts about json, ajax, etc, but I am still not quite clear. Can anybody tell me how to do thi

Re: help passing data from view to template

2005-12-21 Thread Colleen Owens
Okay, yeah this was a dumb question, foolishly asked before I got through part 4 of the tutorial. I see now that calling get_link_list from within my template will do what I need. I didn't realize that get_link_list would preserve ordering.On 12/21/05, Colleen Owens <[EMAIL PROTECTED]> wrote: I'm a

help passing data from view to template

2005-12-21 Thread Colleen Owens
I'm a Django newbie. This follows up on a question I asked before and a very helpful answer to on this list. So I have a list of dates and for each date I have a list of link objects I want to display. I'm trying to figure out how to best pass this data from my view to the template. I tried this