1

I want to put my variable user_serialized_xml in my HTML template, but I am not sure how can I do it :/

This is my views.py

> def user_xml(request):
>     context = {}
> 
>     user_serialized_xml = serializers.serialize("xml", Usuario.objects.all())
>     context['user_serialized_xml'] = user_serialized_xml
>     return render_to_response('profile_xml.html', context)

And this is my HTML template (yes, really short!):

<!DOCTYPE html>

{{user_serialized_xml}}

It gives me this error: Could not parse the remainder: '{user_serialized_xml' from '{user_serialized_xml'

Thank you!

3
  • 1
    You only closed 2 curly brackets​ but opened 3. Commented May 21, 2017 at 13:16
  • Sorry, it was a fail on the post ! Edited :) Commented May 21, 2017 at 13:25
  • right now your code is correct, I have tested, it works. Commented May 21, 2017 at 14:54

1 Answer 1

2

Try rendering in your template like this,

{{ user_serialized_xml | safe }}

It will avoid escaping HTML characters. For more information, see this docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.