随笔分类 -  python

摘要:代码: 参考资料: http://www.th7.cn/Program/Python/201607/902253.shtml https://docs.djangoproject.com/en/dev/howto/custom-management-commands/ 阅读全文
posted @ 2016-10-15 12:58 junneyang 阅读(447) 评论(0) 推荐(0)
摘要:代码: 启动 我们都用过Django的django-admin.py和manage.py。django-admin.py是一个命令行工具,可以执行一些管理任务,比如创建Django项目。而manage.py是在创建每个Django project时自动添加在项目目录下的,只是对manage.py的一 阅读全文
posted @ 2016-10-15 11:33 junneyang 阅读(658) 评论(0) 推荐(0)
摘要:参考资料: XML读写 推荐:http://blog.csdn.net/gingerredjade/article/details/21944675 http://bbs.csdn.net/topics/350027413 http://bbs.csdn.net/topics/390194606 h 阅读全文
posted @ 2016-10-14 16:23 junneyang 阅读(1240) 评论(0) 推荐(0)
摘要:代码: Django默认的事务行为 默认情况下,在Django中事务是自动提交的。当我们运行Django内置的模板修改函数时,例如调用model.save()或model.delete()时,事务将被立即提交。这种机制和数据库的自动提交事务机制类似。记住这里没有默认的回滚机制。 在HTTP请求上加事 阅读全文
posted @ 2016-10-13 10:54 junneyang 阅读(2775) 评论(0) 推荐(1)
摘要:Model定义: datetime转化为时间戳: 时间戳转化为datetime: 参考资料: http://stackoverflow.com/questions/13225890/django-default-timezone-now-saves-records-using-old-time 时间 阅读全文
posted @ 2016-10-13 09:16 junneyang 阅读(1677) 评论(0) 推荐(0)
摘要:参考资料: https://docs.python.org/2/library/uuid.html http://www.cnblogs.com/dkblog/archive/2011/10/10/2205200.html http://www.zhihu.com/question/19742113 阅读全文
posted @ 2016-10-10 18:30 junneyang 阅读(5730) 评论(0) 推荐(0)
摘要:参考资料: http://zh-sphinx-doc.readthedocs.io/en/latest/tutorial.html http://avnpc.com/pages/writing-best-documentation-by-sphinx-github-readthedocs http: 阅读全文
posted @ 2016-09-27 09:32 junneyang 阅读(1350) 评论(0) 推荐(0)
摘要:This can happen if the code is expired. They expire pretty quickly by default. You can look up your code in the Django admin under Grants and change t 阅读全文
posted @ 2016-05-17 16:13 junneyang 阅读(558) 评论(0) 推荐(0)
摘要:项目代码见GitHub:https://github.com/junneyang/openstack-customization-example 参考资料: Install and configure Horizon:http://docs.openstack.org/mitaka/install- 阅读全文
posted @ 2016-05-14 14:56 junneyang 阅读(1870) 评论(3) 推荐(0)
摘要:libcloud 是一个访问云计算服务的统一接口,该项目已经成为 Apache 组织的顶级项目,采用 Python 开发。 Apache基金会于5月25日宣布,Libcloud已完成孵化、成为顶级项目。 One Interface To Rule Them All Python library fo 阅读全文
posted @ 2016-05-14 14:46 junneyang 阅读(1134) 评论(0) 推荐(0)
摘要:1、JS 2、Python 3、Django模板 参考资料: python中的urlencode与urldecode :http://blog.csdn.net/haoni123321/article/details/15814111 阅读全文
posted @ 2016-05-14 09:47 junneyang 阅读(1372) 评论(0) 推荐(0)
摘要:配置Django Admin,关于如何启用请参考Django官方文档《Activate the admin site》。但是我在配置过程中登录http://example.com/admin后台时出现样式表丢失的问题,比如说界面变成了这样: 上网搜索了不少文档,多是Apache环境下的解决方案,我配 阅读全文
posted @ 2016-03-31 15:22 junneyang 阅读(6947) 评论(0) 推荐(0)
摘要:好的日志对一个软件的重要性是显而易见的。如果函数的入口都要写一行代码来记录日志,这种方式实在是太低效了,但一直没有找到更好的方法。后来用python写一些软件,了解到python的装饰器功能时,突然人品爆发,结合装饰器来记录日志那是绝对的简单有效! 下面简单演示一下用装饰器来协助记录Log,示例代码 阅读全文
posted @ 2016-03-29 11:31 junneyang 阅读(4849) 评论(0) 推荐(1)
摘要:from django.db.models import QItem.objects.filter(Q(creator=owner) | Q(moderated=False)) 代码示例: 参考资料: http://stackoverflow.com/questions/739776/django- 阅读全文
posted @ 2016-03-28 12:04 junneyang 阅读(3414) 评论(0) 推荐(0)
摘要:使用示例1.创建用户>>> from django.contrib.auth.models import User>>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')# At this 阅读全文
posted @ 2016-03-28 11:41 junneyang 阅读(1437) 评论(0) 推荐(0)
摘要:A ReSTful API is becoming a standard component of any modern web application. The Django Rest Framework is powerful framework for developing ReST endp 阅读全文
posted @ 2016-03-28 09:58 junneyang 阅读(382) 评论(0) 推荐(0)
摘要:参考资料: Django Ajax CSRF 认证:http://www.ziqiangxuetang.com/django/django-csrf.html Python Post遇到csrftoken问题 :http://zhidao.baidu.com/link?url=rz3djY2XyPo 阅读全文
posted @ 2016-03-28 09:46 junneyang 阅读(209) 评论(0) 推荐(0)
摘要:此文是总结Django官方网站里面的Document的文章 User authentication in Django http://www.djangoproject.com/documentation/authentication/ 该模块由 用户(Users) 权限(Permissions) 阅读全文
posted @ 2016-03-28 09:32 junneyang 阅读(3420) 评论(0) 推荐(0)
摘要:按手册和网上的方法在settings.py中设置“SESSION_COOKIE_AGE” 和 “SESSION_EXPIRE_AT_BROWSER_CLOSE” 均不生效。 通过查看django的源代码"middleware.py"才知道这两个参数只有在settings.SESSION_SAVE_E 阅读全文
posted @ 2016-03-28 09:27 junneyang 阅读(1698) 评论(0) 推荐(0)
摘要:参考资料: Mako Templates for Python官网:http://www.makotemplates.org/ Python模板库Mako的用法:http://my.oschina.net/u/877170/blog/290438 Mako 1.0.4 Documentation:h 阅读全文
posted @ 2016-03-17 12:14 junneyang 阅读(773) 评论(0) 推荐(0)