Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7046101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:36:37+00:00 2026-05-28T02:36:37+00:00

In the docs it says: The only exceptions are variables that are already marked

  • 0

In the docs it says:

The only exceptions are variables that are already marked as “safe” from escaping, either by the code that populated the variable, or because it has had the safe or escape filters applied.”

How does the “populated the variable” part work ? I’m actually looking for a way to declare a template tag as safe in the view. I somehow think it’s not a good idea to let a designer decide. My co-worker will just add it whenever she ‘thinks’ it’s a good idea.

https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:36:38+00:00Added an answer on May 28, 2026 at 2:36 am

    Django has a subclass of strings called safe strings (specifically SafeUnicode or SafeString), which can be created using django.utils.safestring.mark_safe. When the template engine comes across a safe string it doesn’t perform HTML escaping on it:

    >>> from django.utils.safestring import mark_safe
    >>> from django.template import Template, Context
    >>> Template("{{ name }}").render(Context({'name': mark_safe('<b>Brad</b>')}))
    u"<b>Brad</b>"
    

    If you’re writing your own template tag, you need to implement render() which will return a string that will be treated as safe, meaning you have to handle any escaping necessary yourself. However if you’re writing a template filter, you can set the attribute is_safe = True on the filter to avoid auto escaping of the returned value, e.g.

    @register.filter
    def myfilter(value):
        return value
    myfilter.is_safe = True
    

    See https://docs.djangoproject.com/en/4.0/howto/custom-template-tags/#filters-and-auto-escaping for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read http://code.google.com/speed/page-speed/docs/caching.html . It says that proxy servers may cache cookies. I need
From http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html#99740 example A3.3 says, it says that an object might still not be
http://docs.python.org/3.0/whatsnew/3.0.html says it lists whats new , but in my opinion, it only lists
The docs says that ancestor will apply a filter of given ancestor being somewhere
Java docs says that a TreeSet keeps its elements ordered internally. Here what does
Tomcat docs says that Normally, application classes should NOT be placed here: $CATALINA_BASE/lib .
so live docs says this for calling .lenght() on an XML object For XML
When using svcutil.exe, I noticed this switch, /tcv:Version35. The docs says this: Version35: Use
OK, maybe I'm dumb/blind, but in the docs it says rebuild and restart the
The docs on ehache says: timeToIdleSeconds: Sets the time to idle for an element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.