I'm not sure if this answers your question, but... I have had better luck using the jQuery.load [1] function. It takes an html response and just jams it into the dom. That way I can do all of the templating and formatting on the server side. The idea of writing "<div id='" + id + "'>" and the like never seemed very maintainable to me. Your html ends up strewn about your javascript in tiny little pieces. Instead make a view that returns the whole portion of the page you need to update (rendered from its own template.) Optionally, you can use the same template that you used to render the first time(non- ajax), using {% if request.is_ajax %} to control what comes through for ajax[2].
I know that is a departure from the standard json response to ajax calls, but then I don't have to do templating in my javascript, which grosses me out. Hope that helps, Alex [1] http://docs.jquery.com/Ajax/load [2] http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.is_ajax On Jul 27, 7:53 am, DaleB <dal...@gmail.com> wrote: > hi all, > > i am just experimenting with ajax following the liveblog-example from > 'python web development with django' (http://withdjango.com/). > everything works really good apart from the fact the i don't manage to > format the serialized data, that is returned by the ajax call: > <code> > jQuery.each(data, function() { > update_holder.prepend('<div id="' + > this.pk + '" class="update ' + cycle_class + '">' > + '<div class="timestamp">' > + this.fields.timestamp > </code> > basically i am trying to adjust the date, which is returned as full > date string (including (month, year etc.) to the rest of the template > where only the hour and the minutes of a postig are displayed. > so... django template-filters don't work and using python's strftime- > function on the returned data has no effect either? > do i have to format the date in my view? but then, how (and where) can > i 'reformat' the date? > the only thing that comes to my mind is copying the requested data to > a list, replace the date and then hand it over to the serializer... > but this is rather complicated, isn't it? > > greetings, > andreas --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---