10511

How do I pass Django's urlize template filter its autoescape parameter?

Question:

Django <a href="https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#urlize" rel="nofollow">urlize docs</a> say:

<blockquote>

The urlize filter also takes an optional parameter autoescape. If autoescape is True, the link text and URLs will be escaped using Django's built-in escape filter. The default value for autoescape is True.

</blockquote>

I'd like to use this parameter, but the documentation says nothing about how to actually pass a keyword argument to a template filter. Is it possible, and if so, how do I do that?

Answer1:

Apparently urlize gets that keyword argument from current autoescape settings, so the way to go seems like

{% autoescape off %}{{ value|force_escape|urlize }}{% endautoescape %}

(if you still want to escape the value)

Recommend

  • Django, html tags not interpreted
  • Symfony: Handling slashes on URL parameters
  • ModelForm class Contact has no attribute '_meta'
  • How do I extend UserCreationForm to include email field
  • How can I join lazy translation in Django?
  • A Read-Only Relational Database on Google App Engine?
  • Django Rest Framework - Best way to deal with API parameter validation errors?
  • Shell environment variables in vagrant files are only passed on first up
  • Escape special characters in MySQL using C# and ASP.Net
  • Alternative for django.db.close_connection()
  • Django : Model Instance history
  • Django-ckeditor not displaying correctly in html
  • Use python dropbox API with django
  • MongoDB Compass Visually Insert Sub-Document
  • Py_InitModule4 with Djapian/Xapian
  • Django how to modify database records by template
  • Can I put a + sign in a folder with IIS?
  • Open hyperlink on click on an ggplot/plotly chart
  • Symfony2 redirect to https route fails (uses wrong port)
  • Base64 as method of sanitizing user input for Mysql
  • Why is django manage.py syncdb failing to create new columns on my development server?
  • Django return user model id with L
  • Django simple Captcha “No module named fields” error
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • Webgrid not refreshing after delete MVC
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Jquery UI tool tip close icon
  • Symfony2: How to get request parameter
  • ORA-29908: missing primary invocation for ancillary operator
  • Web-crawler for facebook in python
  • QuartzCore.framework for Mono Develop
  • RestKit - RKRequestDelegate does not exist
  • Traverse Array and Display in markup
  • trying to dynamically update Highchart column chart but series undefined
  • Qt: Run a script BEFORE make
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can I use `wmic` in a Windows PE script?
  • java string with new operator and a literal