Enter HTML in MySQL in Django (Save?)

Asked 1 years ago, Updated 1 years ago, 109 views

I'm sorry to bother you at such a busy time.
This is my first time to ask you a question.

I was creating an application on Django this time, but
When creating one page, save each HTML tag in MySQL and
When I tried to call it if necessary, the HTML tag did not appear valid and
Everything was printed as a string.
(It does not act as an HTML tag and the tag is displayed)

I couldn't find a particular answer to Google teacher, so I kept thinking about it.

I would appreciate it if you could tell me how to solve it.

Example)
Save to MySQL (model models.TextField())

<a href="http://hogehoge.com/" target="_blank">Hogehoge Secret</a>

Call to HTML page from Django

<a href="http://hogehoge.com/" target="_blank">Hogehoge Secret</a>"

(Tags do not take effect and appear as is)

I think it is probably treated as a string including tags, but
HTML tags cannot be enabled

html mysql python3 django

2022-09-30 20:21

1 Answers

If {{data|safe}} instead of {{data}}} when calling HTML (template) side, it will be displayed without escape. What do you think?

Note: Django Template Language


2022-09-30 20:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.