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 54647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:15:10+00:00 2026-05-10T17:15:10+00:00

My Django app has a Person table, which contains the following text in a

  • 0

My Django app has a Person table, which contains the following text in a field named details:

<script>alert('Hello');</script>

When I call PersonForm.details in my template, the page renders the script accordingly (a.k.a., an alert with the word ‘Hello’ is displayed). I’m confused by this behavior because I always thought Django 1.0 autoescaped template content by default.

Any idea what may be going on here?

UPDATE: Here’s the snippet from my template. Nothing terribly sexy:

{{ person_form.details }} 

UPDATE 2: I have tried escape, force-escape, and escapejs. None of these work.

  • 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. 2026-05-10T17:15:11+00:00Added an answer on May 10, 2026 at 5:15 pm

    You need to mark the values as | safe I think (I’m guessing that you’re filling in the value from the database here(?)):

    {{ value|safe }} 

    Could you post a sample of the template? Might make it easier to see what’s wrong

    [Edit] ..or are you saying that you want it to escape the values (make them safe)? Have you tried manually escaping the field:

    {{ value|escape }} 

    [Edit2] Maybe escapejs from the Django Project docs is relevent:

    escapejs  New in Django 1.0.  Escapes characters for use in JavaScript strings. This does not make the string safe for use in HTML, but does protect you from syntax errors when using templates to generate JavaScript/JSON. 

    [Edit3] What about force_escape:

        {{ value|force_escape }} 

    …and I know it’s an obvious one, but you’re absolutely certain you’ve not got any caching going on in your browser? I’ve tripped over that one a few times myself 😉

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

Sidebar

Related Questions

I'm creating a Django app in which I have a table which has 'items',
I'm trying to order models in a Django app using a field that has
I have an app named main in my Django project. This app has a
The other person on my dev team has been deploying our Django app to
In my django app, a logged in user can create an Entry which has
In a Django app, I'm having a model Bet which contains a ManyToMany relation
My django app (let me call it partlysecureapp )has an index page which is
I have a django app which has html templates and I also have a
I have a reviews/ratings web application, a la Digg. My django app content has
I have a client that has an app built with django. On every page

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.