博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2019年1月7日

摘要: 利用cookie实现: utils中paginations.py不变,跟上上个随笔一样。 views: page.html 阅读全文

posted @ 2019-01-07 22:45 alex_hrg 阅读(205) 评论(0) 推荐(0) 编辑

2019年1月5日

摘要: cookie的理解可以为,存放在用户浏览器上的一个文件,里面是键值对数据,用于跟服务端通讯。前端可以通过jquery cookie插件设置和读取,后端直接设置 1、获取Cookie: 1 2 3 4 5 6 request.COOKIES['key'] request.get_signed_cook 阅读全文

posted @ 2019-01-05 16:52 alex_hrg 阅读(865) 评论(0) 推荐(0) 编辑

2018年12月25日

摘要: 简单版: 1,views from django.shortcuts import render,HttpResponse from django.utils.safestring import mark_safe # Create your views here. def page(request 阅读全文

posted @ 2018-12-25 17:02 alex_hrg 阅读(212) 评论(0) 推荐(0) 编辑

摘要: str='<a href="/page?page=1">1</a>' 一,在前端模板语言中实现,只须用到帮助函数safe.如: {{ str|safe }} 二,在后端views中实现: from django.utils.safestring import mark_safe str = mark 阅读全文

posted @ 2018-12-25 16:59 alex_hrg 阅读(422) 评论(0) 推荐(0) 编辑

2018年12月24日

摘要: 模板语言自带的一些处理函数:通过管道符来处理 帮助方法:{{ item.event_start|date:"Y-m-d H:i:s"}} 转换成日期时间型{{ bio|truncatewords:"30" }} 只取前30个字符{{ my_list|first|upper }} 将第一个字母大写{{ 阅读全文

posted @ 2018-12-24 20:29 alex_hrg 阅读(225) 评论(0) 推荐(0) 编辑

2018年12月19日

摘要: 一,使用{% block name %}{% endblock %}定义一个模板,在模板页面中它的内容为空,在各页面用{% block name %}自己的标签内容{% endblock %}调用。 模板可以有多个,在各继续页面得用{% extends 'master.html' %}标明 二,{% 阅读全文

posted @ 2018-12-19 21:05 alex_hrg 阅读(774) 评论(0) 推荐(0) 编辑

2018年12月18日

摘要: 创建多对多: 方式一:自定义关系表 class Host(models.Model): nid = models.AutoField(primary_key=True) hostname = models.CharField(max_length=32,db_index=True) ip = models.GenericIPAddressField(protocol="i... 阅读全文

posted @ 2018-12-18 18:51 alex_hrg 阅读(172) 评论(0) 推荐(0) 编辑

2018年12月17日

摘要: $('#ajax_submit').click(function () { $.ajax({ 'url':'/app_ajax', 'type':'post', 'data':$("#f1").serialize(), #将一个form表单全部发送到后台 {# ... 阅读全文

posted @ 2018-12-17 22:41 alex_hrg 阅读(208) 评论(0) 推荐(0) 编辑

2018年12月12日

摘要: 通常做法是,用ajax提交,在数据库删除条目,而页面不用刷新,直接找到相应的html标签 remove掉。这样比较人性化 阅读全文

posted @ 2018-12-12 22:32 alex_hrg 阅读(179) 评论(0) 推荐(0) 编辑

2018年12月7日

摘要: 很多页面用到的模态对话框,如知明网站https://dig.chouti.com/的登录页都是模态对话框, 当点登录时,是用的ajax提交,因为输入错了信息,有返回消息,而页面没有刷新。 jquery ajax格式: #models from django.db import models # Cr 阅读全文

posted @ 2018-12-07 21:06 alex_hrg 阅读(2216) 评论(0) 推荐(0) 编辑