发表文章

这节主讲的是如何利用在线编辑器发表文章

主要动作有  在页面网页中配置出编辑文章视图->将文章上传到后台数据库

一:在网页上配置出编辑文章视图

1.这里我用的是ueditor,主要配置参考相关文章

2.在网页上添加自己的提交按钮,如图

<!DOCTYPE html>
<html>
<head>
	<title>Live for interesting</title>
	<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="static/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="static/ueditor/ueditor.all.js"></script>
</head>
<body>

<form action="../editor" method="POST">
<div>
	<span class="cTit">标题:</span>
	<input name="title" type="text" size="96" value=""><br>
	<span class="cTit">主题:</span>
	<input name="summary" type="text" size="96" value="">
	
	<textarea id="editor" name="container" style="width: 800px; height: 400px; margin: 0 auto;"></textarea>
	<input type="submit" value="提交">
</div>	
</form>

</body>
<script type="text/javascript">
		var ue=UE.getEditor('editor');
</script>	

</html>

二:将上传的数据写往数据库

def editor(req):
	models.LFI.objects.create(
		title=req.POST.get("title"),
		category=models.Category.objects.get(id=1),
		summary=req.POST.get("summary"),
		content=req.POST.get("container"),
		author=models.LFI_user.objects.get(user=req.user),
		view_count=0,
		ranking=0
	)
	return render_to_response("editor.html")

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值