2
我正在遷移到「漂白」,我遵循了turboial中的所有步驟,但當我在html中調用{{ post.content|bleach }}
時出現錯誤。我正在使用Django 1.8版本。另外在我的管理員,它沒有認出我的CKeditor。Django - 無效的過濾器漂白
頁面中的錯誤信息是:
Request Method: GET
Exception Value: Invalid filter: 'bleach'
在服務器的日誌我:
/home/ubuntu/workspace/wpage/urls.py:26: RemovedInDjango19Warning: Default value of 'RedirectView.permanent' will change from True to False in Django 1.9. Set an explicit value to silence this warning.
url(r'^.*/$', RedirectView.as_view(url='/blog/')),
下面是我的一些文件:
setting.py:
INSTALLED_APPS = (
...
'django_bleach',
)
...
BLEACH_ALLOWED_ATTRIBUTES = ['href', 'title', 'style']
BLEACH_ALLOWED_STYLES = [
'font-family', 'font-weight', 'text-decoration', 'font-variant']
BLEACH_STRIP_TAGS = True
BLEACH_STRIP_COMMENTS = False
BLEACH_DEFAULT_WIDGET = 'ckeditor.widgets.CKEditorWidget'
model s.py:
from django.db import models
from django_bleach.models import BleachField
class Post(models.Model):
...
content = BleachField()
base.html文件:
{% load staticfiles %}
{% load bootstrap3 %}
{% load bleach_tags %}
...
post.html:
{% extends "base.html" %}
{% block content %}
<div> {{ post.content|bleach }} </div>