我目前正在尝试在我的Web项目中实现TinyMCE(django-tinymce4-lite /-http://romanvm.github.io/django-tinymce4-lite/),但是由于某些原因,我无法以前端形式保存该字段的内容。我是从django管理员后端完成的,它的工作无懈可击。
models.py:
#Post Model
class Post(models.Model):
author = models.ForeignKey('accounts.User', on_delete=models.CASCADE)
title = models.CharField(max_length=75)
content = HTMLField('Content')
tag = models.CharField(max_length=50, blank=True)
...
base.html:
<!DOCTYPE html>
<html lang="en">
<html>
<head>
{{ form.media }}
<title>{{ settings.SITE_NAME }}</title>
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-theme.min.css' %}">
...
forms.py
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ['title', 'category', 'tag', 'postcover', 'postattachment',]
content = forms.CharField(widget=TinyMCE(mce_attrs={'width': 800}))
...
知道为什么我不赞成将内容保存在前端表单中吗?
感谢阅读