摘要: django 使用内建过滤器实现文章摘要效果 前端html代码 使用truncatechar_html选择文章内容的前一百个字符,不包括html标签。 文档地址:http://python.usyiyi.cn/django_182/ref/templates/builtins.html 阅读全文
posted @ 2016-04-24 22:00 hb91 阅读(664) 评论(0) 推荐(0) 编辑
摘要: 分页效果: 视图代码: paginator是分页实例,page是链接传递到后端的页码参数,articles是每页的实例。 在次例中,paginator是把所有文章(article_list)按照每页两个划分,划成3页。page是前端请求的页码。articles是根据请求页码返回的具体的该页码内的文章 阅读全文
posted @ 2016-04-23 20:41 hb91 阅读(1885) 评论(0) 推荐(0) 编辑
摘要: 使用django-admin-bootstrappe快速美化后台 两步: 1、pip install django-admin-bootstrapped 安装应用 2、在setting.py里面添加 django-admin-bootstrappe列表 效果 链接地址: https://github 阅读全文
posted @ 2016-04-23 11:57 hb91 阅读(11138) 评论(2) 推荐(0) 编辑
摘要: 看下面两个页面: —————————————————————————————————————————————————————————————————————————————————— 一个显示文章列表,一个显示文章详细信息,其中的部分内容相同,有可以重用的部分。 所有就此例可以设置三个html文件: 阅读全文
posted @ 2016-04-22 23:11 hb91 阅读(4464) 评论(0) 推荐(0) 编辑
摘要: 一、下载bootstrap相关文件,放在项目目录中。在blog 应用中新建static目录,bootstrap文件放在此目录下。 bootstrap下载网址:http://v3.bootcss.com/getting-started/ 项目目录: 然后根据django1.8.2文档的简单教程修改HT 阅读全文
posted @ 2016-04-20 22:40 hb91 阅读(4004) 评论(0) 推荐(0) 编辑
摘要: 前提: 代码结构 步骤一: 下面为某个网页的链接地址 其中的链接地址为: 第二层 blog中的url.py 步骤三: 然后调用view.detail (在view.py中) 步骤四: 然后返回 目录 blog/p/detail.html 根据article.id值在数据库中查找相应字段,填充arti 阅读全文
posted @ 2016-04-19 23:02 hb91 阅读(657) 评论(0) 推荐(0) 编辑
摘要: django的默认语言为英语,默认时间为UTC。 在settings.py中更改语言和时间 改为 效果 阅读全文
posted @ 2016-04-18 18:37 hb91 阅读(482) 评论(0) 推荐(0) 编辑
摘要: ******************************************************** http://jingxuan.io/progit/2-Git%E5%9F%BA%E7%A1%80.html 忽略某些文件 一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出 阅读全文
posted @ 2016-04-17 21:23 hb91 阅读(2583) 评论(0) 推荐(0) 编辑
摘要: hb@hb-pc ~ $ virtualenv --python=python3 --no-site-packages test Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in test/bin/python3 Also creatin... 阅读全文
posted @ 2016-04-17 19:42 hb91 阅读(413) 评论(0) 推荐(0) 编辑
摘要: 1、字典创建 zip函数创建 dict.formkeys创建字典 fromkeys(iterable, value=None, /) method of builtins.type instance Returns a new dict with keys from iterable and val 阅读全文
posted @ 2016-03-12 11:42 hb91 阅读(2982) 评论(0) 推荐(0) 编辑
摘要: 1、 S.partition(sep) -> (head, sep, tail) Search for the separator sep in S, and return the part before it, the separator itself, and the part after it 阅读全文
posted @ 2016-03-11 21:39 hb91 阅读(532) 评论(0) 推荐(0) 编辑
摘要: maketrans 和 translate的用法(配合使用) 下面是python的英文用法解释 maketrans(x, y=None, z=None, /) Return a translation table usable for str.translate(). If there is onl 阅读全文
posted @ 2016-03-11 20:44 hb91 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 1、S.isdecimal() -> bool Return True if there are only decimal characters in S, False otherwise. 字符串如果是十进制,返回True。 2、S.isdigit() -> bool Return True if 阅读全文
posted @ 2016-03-11 17:11 hb91 阅读(537) 评论(0) 推荐(0) 编辑
摘要: python3 字符串属性 1 >>> a='hello world' 2 >>> dir(a) 3 ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__ 阅读全文
posted @ 2016-03-10 22:41 hb91 阅读(2624) 评论(0) 推荐(0) 编辑
摘要: 版本:python2.7.6 lambda filter() map() reduce() 三点:输入,作用,输出 1、lambda lambda 参数:表达式 返回值为表达式的值 1 >>> f=lambda x,y:x*y 2 >>> f(4,6) 3 24 参数匿名 1 >>> L=[lamb 阅读全文
posted @ 2016-03-06 10:54 hb91 阅读(213) 评论(0) 推荐(0) 编辑