You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accessing an API view with rest-framework-latex's renderer enabled throws a
ValueError
dictionary update sequence element #0 has length 13; 2 is required
Hack
Change rest_framework/compat.py from
# backends template, e.g. django.template.backends.django.Template
else:
return template.render(context, request=request)
to
# backends template, e.g. django.template.backends.django.Template
else:
return template.render(dict(data=context), request=request)
so I can access it in my latex template like so
{% for obj in data %}
{{ obj.some_field_that_my_api_exports|latex_safe }}
{% endfor %}
context is originally an OrderedDict of my queryset.
This is apparently absolutely required by all other renderers like the Browseable API renderer.
However, I couldn't figure out a way to access the OrderedDict in my template without wrapping it into a dict.
Unless I'm missing a straight-forward way to access the OrderedDict from the template, would it be possible to change LatexRenderer.render() to wrap data into a normal dict?
The text was updated successfully, but these errors were encountered:
florianm
changed the title
[Solution] Django 1.10: ValueError: dictionary update sequence element #0 has length xx; 2 is required
Django 1.10: ValueError: dictionary update sequence element #0 has length xx; 2 is required
Oct 21, 2016
Hi folks, just got first light on some sweet PDF output from your neat extension but I'm running into a weird bug in django-rest-framework.
Environment
config:
Expected
PDF output via rest-framework-latex
Error
Accessing an API view with rest-framework-latex's renderer enabled throws a
Hack
Change
rest_framework/compat.py
fromto
so I can access it in my latex template like so
context
is originally an OrderedDict of my queryset.This is apparently absolutely required by all other renderers like the Browseable API renderer.
However, I couldn't figure out a way to access the OrderedDict in my template without wrapping it into a dict.
Unless I'm missing a straight-forward way to access the OrderedDict from the template, would it be possible to change
LatexRenderer.render()
to wrapdata
into a normal dict?Sending PR for review and discussion.
The text was updated successfully, but these errors were encountered: