В документации https://pythonhosted.org/django-webodt/tables.html описано как работать с таблицами. Всё кажется простым и понятным.
Я пишу шаблонные теги:
{% xmlfor с in contragents %}{{forloop.counter}}|{{c.name}}{% endxmlfor %}
Вот моё view:
def contracts(request):
try:
contragents = Contragent.objects.all().order_by('name', )
except:
contragents = None
if request.method == 'POST':
if 'btnSave' in request.POST or 'btnSaveEdit' in request.POST:
template = webodt.ODFTemplate('contract-r.odt')
context = {'contragent':'John Doe', 'representative':'Johnny', 'basis':'основания', 'contragents':contragents,}
document = template.render(Context(context))
#conv = converter()
#pdf = conv.convert(document, format='pdf')
response = HttpResponse(document , content_type='application/odt')
response['Content-Disposition'] = 'attachment; filename=%s.odt' % (datetime.today().strftime("%d.%m.%Y_%H-%M"))
return response
else:
return render_to_response('contracts.html', {'active_contracts':'active', 'contragents':contragents,}, RequestContext(request))
Возвращает ошибку: Unexpected {% endxmlfor %} tag near {{c.name}}{% endxmlfor %}
Подскажите как это исправить? Или, если можно, покажите рабочий пример.