models.py
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = RichTextUploadingField()
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
url.py
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/login/$', views.login, name='login'),
url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}),
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
url(r'', include('blog.urls')),
]
# serving media files only on debug mode
if settings.DEBUG:
urlpatterns += [
url(r'^media/(?P<path>.*)$', serve, {
'document_root': settings.MEDIA_ROOT
}),
]
我将使用CKeditor上传图片。 没有错误。 但是,它看起来像一张照片。
答案 0 :(得分:0)
在模板中渲染html时,请确保将其标记为安全...
{{ article.text|safe }}
参见文档:
https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#safe