James L.
James L.

Reputation: 1153

Print apostrophe in python string

I've this view in my view

def terms(request):
    d = getVariables(request,dictionary={'page_name': "Jack's Terms of Service"})  
    return render(request, 'jack/terms.html', d)

I'm rendering this as a page title in the templates

<title>{{ page_name }}</title>

But for some reason it prints the page_ name like this

<title>Jack&#39;s Terms of Service</title>

I don't know why it's not printing the apostrophe in the string.

Upvotes: 2

Views: 1087

Answers (1)

Marcos Aguayo
Marcos Aguayo

Reputation: 7200

Use safe. It marks a string as not requiring further HTML escaping prior to output.

<title>{{ page_name|safe }}</title>

Documentation here: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe

Upvotes: 4

Related Questions