The big issue here would be why to do that.  If you are doing this
synchronously, why put the data into a json object.  Just pass a
dictionary and do what yo will.  If you are doing this ansynchronously
(ala AJAX) then the page will not reload and the template will already
be compiled and unable to incorporate any new information passed
asynchronously.  One thing that you can do is to pass a
render_to_response call a template and the python dictionary you want
modified and let django work its majic on it before returning the
'._container' to the page via json.  You will still have to use some
javascript to display the new information.  I use this mechanism
extensively in an app I am currently writing, but am partial to the
YUI rather than dojo.
-richard


On Sep 14, 12:35 pm, robo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am able to send JSON data from Django to my javascript function, but
> I would like to iterate JSON by using the Django template language. Is
> this possible at all?
>
> For example, my view passing JSON back:
> def ajax_form_test(request):
>   data = serializers.serialize("json", Order.objects.all())
>   if request.method == 'POST':
>     return HttpResponse(data, mimetype="application/json")
>
> And my Javascript function that receives JSON:
>
>    function hello() {
>      var form_data = {
>         url: "/ajax_form_test/",
>         handleAs: "json",
>         load: function(data){
>           dojo.byId("myDiv1").innerHTML = data;
>         },
>         error: function(data){
>                 alert("Holy Bomb Box, Batman!  An error occurred: " +
> data);
>         },
>         timeout: 5000,
>         form: "myForm"
>     };
>     dojo.xhrPost(form_data);
>    }
>
> Right now the way my template displays JSON is by using innerHTML as
> above. But I would like to convert the data somehow so that Django can
> iterate in the {{...}} syntax.
>
> Thanks,
>
> robo


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to