urlpatterns += [
url(r'^article/$',article,name='article'),
url(r'^upload/(?P<dir_name>[^/]+)$',upload),
]
views界面
#文章编写界面
def article(request):
errors = []
if request.method == 'POST':
if not request.POST.get('title',''):
errors.append('Enter a title')
if not request.POST.get('desc',''):
errors.append('Enter a desc')
if not request.POST.get('content',''):
errors.append('Enter a content')
if not errors:
return HttpResponse('Thank you ...')
return render(request,'article.html')
html页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>写点什么</title>
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/kindeditor-min.js'></script>
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/lang/zh_CN.js'></script>
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/config.js'></script>
</head>
<body>
<div id="content" class="col">
<h1>我的文章</h1>
{%if errors%}
<ul>
{%for error in errors%}
<li>{{error}}</li>
{%endfor%}
</ul>
{%endif%}
<form enctype="multipart/form-data" action="" method="post" id = "article_form"></form>
{%csrf_token%}
<div>
<label for="id_title">文章标题</label>
<input type="text" name="desc" maxlength="50" value="{{desc}}">
</div>
<hr>
<div>
<label for="id_title">文章描述</label>
<input type="text" name="desc" maxlength="50" value="{{desc}}">
</div>
<hr>
<div>
<label for="id_content">文章内容</label>
<textarea id="id_content" type="text" name="content" maxlength="50" value="{{content}}"></textarea>
</div>
<div>
<input type="submit" value="保存" name="_save">
</div>
</div>
</body>
</html>
最主要的是导入一个js文件
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/kindeditor-min.js'></script>
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/lang/zh_CN.js'></script>
<script type="text/javascript" src = '/static/js/kindeditor-4.1.10/config.js'></script>