随笔分类 -  python+django

摘要:django版本:1.4.21。一、准备工作1、新建项目和app[root@yl-web-test srv]# django-admin.py startproject lxysite[root@yl-web-test srv]# cd lxysite/[root@yl-web-test lxysi... 阅读全文
posted @ 2015-08-12 23:01 starof 阅读(22089) 评论(0) 推荐(3) 编辑
摘要:一、默认日志配置在django 1.4中默认有一个简单的日志配置,如下# A sample logging configuration. The only tangible logging# performed by this configuration is to send an email to... 阅读全文
posted @ 2015-08-05 19:49 starof 阅读(2477) 评论(0) 推荐(0) 编辑
摘要:python的日志模块为logging,它可以将我们想要的信息输出保存到一个日志文件中。# cat log import logginglogging.debug('This is debug message')logging.info('This is info message')logging.... 阅读全文
posted @ 2015-08-05 17:28 starof 阅读(1519) 评论(0) 推荐(0) 编辑
摘要:python 中curses封装了c语言的curses,把c中复杂部分简单化,比如addstr(),mvaddstr(),mvwaddstr()合并成了一个addstr()方法。一、语法入门1、打开和关闭一个curses 应用程序在任何代码执行前都先要初始化curses。初始化操作就是调用inits... 阅读全文
posted @ 2015-08-05 13:48 starof 阅读(41225) 评论(4) 推荐(2) 编辑
摘要:一、django静态文件配置原理静态文件配置就是为了让用户请求时django服务器能找到静态文件返回。首先要理解几个概念:媒体文件:用户上传的文件静态文件:css,js,image等开发环境:使用django内置服务器处理静态文件生产环境:使用apache2/nginx服务器处理静态文件映射所以在配... 阅读全文
posted @ 2015-07-30 08:56 starof 阅读(34822) 评论(0) 推荐(2) 编辑
摘要:一、安装httpd服务apache在centos7中是Apache HTTP server。如下对httpd的解释就是Apache HTTP Server。所以想安装apache其实是要安装httpd。httpd.x86_64 : Apache HTTP Server安装:# yum install... 阅读全文
posted @ 2015-07-29 17:38 starof 阅读(28306) 评论(1) 推荐(0) 编辑
摘要:paramiko 遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接,可以实现远程文件的上传,下载或通过ssh远程执行命令。项目地址:https://github.com/paramiko/paramiko官方文档:http://docs.paramiko.org/一、安装root@ub... 阅读全文
posted @ 2015-07-23 21:03 starof 阅读(12902) 评论(1) 推荐(1) 编辑
摘要:一、起因今天在做角色控制中,有一个地方用到rstrip,判断用户请求的url是否与数据库对应可用权限中url相符。if request.path == x.url or request.path.rstrip('/') == x.url: #精确匹配,判断request.path是否与permiss... 阅读全文
posted @ 2015-07-16 22:57 starof 阅读(4556) 评论(0) 推荐(0) 编辑
摘要:一、问题今天网站出了一个错误:RuntimeError at /index.htmlclass.__dict__ not accessible in restricted mode二、原因用了两次WSGIScriptAlias,类似于:WSGIScriptAlias /my_app /home/my... 阅读全文
posted @ 2015-04-21 09:43 starof 阅读(759) 评论(0) 推荐(0) 编辑
摘要:方法一:用元类的方式实现一个singleton。liuxiaoyan@development:~/mysite$ cat Singleton.py class Singleton(type): """Singleton Metaclass""" def __init__(... 阅读全文
posted @ 2015-03-05 14:16 starof 阅读(623) 评论(0) 推荐(0) 编辑
摘要:用django时,只要用到数据库就得用到模型。一、数据库的MTV开发模式从MVC到MTV所谓软件架构的MVC模式将数据的存取逻辑(Module),表现逻辑(View)和业务逻辑(Controller)分开,降低耦合。Module代表数据库的存取,View代表系统中选择显示什么和怎样显示,Contro... 阅读全文
posted @ 2015-03-04 20:35 starof 阅读(1715) 评论(5) 推荐(1) 编辑
摘要:表单是交互性网站的支柱。 本文内容包括django对表单提交数据的访问,有效性检查以及其他处理,还有HttpRequest对象和Form对象。 一、HttpRequest的URL相关信息 定义views.py 可以显示出: 二、request.META 显示所有META,在views.py里增加函数 阅读全文
posted @ 2015-02-10 16:40 starof 阅读(3527) 评论(6) 推荐(1) 编辑
摘要:所谓网页开发是有趣的,管理界面是千篇一律的。所以就有了django自动管理界面来减少重复劳动。一、激活管理界面1、django.contrib包django自带了很多优秀的附加组件,它们都存在于django.contrib包里,与django捆绑,使开发人员不需要重复造轮子。django.contr... 阅读全文
posted @ 2015-02-09 10:40 starof 阅读(2758) 评论(2) 推荐(4) 编辑
摘要:一、pip安装安装:apt-get updateapt-get install python-pippip install django==1.4.20卸载:pip uninstall django==1.4.20二、源码安装1、下载源码和安装下载Djangowget www.djangoproje... 阅读全文
posted @ 2015-01-26 10:48 starof 阅读(25064) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示