To trim last colon wrap it with if statement: {% if forloop.revcounter0 %},{% endif %}
On Wed, Dec 3, 2008 at 04:26, Viktor Nagy <[EMAIL PROTECTED]> wrote: > Hi, > > I know about the serialisation framework, but with MultiResponse[1] you > can't really use it (and anyway I don't know how to customise it > extensively). As a result I would like to create json with the django > template engine. > > An example code would be this: > > [{% for poll in data %} > {"question": "{{ poll.question }}"}, > [ {% for answer in poll.answer_set.all %} > {"answer": "{{ answer.answer }}", > "votes": {{ answer.votes }}, > "vote_url": "{% url multi_api_data data=answer.pk %}",}, > {% endfor %} ]}, > {% endfor %} ] > > But at parsing simplejson.py gives an error. The error is easy to > understand with the following example: > ["a"] <- this is fine for simplejson.loads > ["a",] <- this kills simplejson.loads > > Any ideas how to generate a for loop without the last colon(,)? Or how to > use json syntax in the template in general? > > thanks, V > > [1]: http://toastdriven.com/fresh/more-multiresponse > > -- > Viktor Nagy - http://viktornagy.com > PhD student > Toulouse School of Economics > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---