我发现这真的很奇怪。当我尝试将数据插入数据库时,它会删除除<p>
html标签以外的所有标签?!
我要插入的示例文字:
<p>Facebook This link should show up... Facebook Facebook CHANGE <a href="http://www.f.com" target="_blank">CHAN</a></p>
我在提交之前将上述文本打印到控制台,如下所示:
print job
if commit:
job.save()
return job
然后当我进入我的mysql
并查看插入的内容时,我得到以下内容:
<p>Facebook This link should show up... Facebook Facebook CHANGE CHAN</p>
正如您所看到的那样,它被删除<a href='http://www.f.com
并将文字留在<a
标记(CHAN)中。
为什么会发生这种情况的任何想法?由于某些原因,html被剥离似乎很奇怪。
答案 0 :(得分:0)
事实证明我的Django-bleach 来自# Set tags for a Bar metal
#
# The script sets the tags for a Bar metal,
# it makes a single call to the SoftLayer_Hardware::setTags method
# For more information please see below.
#
# Important manual pages:
# http://sldn.softlayer.com/reference/services/SoftLayer_Hardware/setTags
#
# License: http://sldn.softlayer.com/article/License
# Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
require 'softlayer_api'
require 'pp'
# Your SoftLayer username and API key.
USERNAME = 'set me'
API_KEY = 'set me'
# The Hardware Id you wish to set the tags
hardware_id = 122145
# The tags you wish to set in the server
tags = 'mytag1, mytag2'
client = SoftLayer::Client.new(username: USERNAME, api_key: API_KEY)
virtual_guest_service = client['SoftLayer_Hardware']
begin
# Sending the request to get the tags
result = virtual_guest_service.object_with_id(hardware_id).setTags(tags)
pp result
rescue StandardError => exception
pp "Unable to set the tags. : #{exception}"
end
并且其设置不允许BleachField()
!所以我不得不进入我的Links
来改变它们。
我是settings.py
的新手,正在开发一个包含大量代码的预建项目!所以这很难找到。
无论如何,请查看此链接以获取更多相关信息:Django admin: allowing some HTML in user input