`
xiaoJay
  • 浏览: 66211 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表

django 时区问题

django 1.6 中 支持时区, 0、 pip install pytz 1、 settings.py 设置成: LANGUAGE_CODE = 'zh_cn' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = True 2、 那么,存入数据库的是 timezone aware 的时间类型(时区默认是UTC) 如果要显示是,要生成当地的时区(比如 UTC+8) import django.utils.timezone as tz print tz.localtime(at ...
http://stackoverflow.com/questions/14246292/python-subprocess-call-blocking subprocess.call block, and 立刻运行命令 p = subprocess.Popen 不运行 当p.wait 时,开始运行 output = subprocess.check_output 立刻运行,如果失败,raise exception
问题 http://v2ex.com/t/68761#reply7 解决方案:自定义了一个filter( filter 类似于 shell 的管道) [url]http://djangobook.py3k.cn/2.0/chapter09/ [/url]具体步骤: 1 在 app 目录建 templatetags dir, 包括一个__init__.py 和tags模块文件(eg: mytags.py) 2 mytags.py 中写代码 #coding=utf-8 from django import template register = template.Library() ...

git tips2

    博客分类:
  • sa
1 How do you discard unstaged changes in git? For a specific file use: git checkout path/to/file/to/revert For all unstaged files use: git checkout -- . Make sure to include the period at the end http://stackoverflow.com/questions/52704/how-do-you-discard-unstaged-changes-in-git

virtualenvwrapper tips

安装 pip install virtualenvwrapper 安装完成后,mkdir ~/Envs 这个是你以后创建的所有env的存储的地方 然后在 .bash_profile export WORKON_HOME=~/Envs source /usr/local/bin/virtualenvwrapper.sh ok,具体使用 创建一个env mkvirtualenv name 查看所有的env lsvirtualenv 进入一个env workon name 退出 deactivate
1 安装 sudo pip install south 在 settings.py 的 installed_app 添加south ./manage.py syncb 将south的表同步到db 2 south 针对每个app 全新的app 一 ./manage.py schemamigration appname --initial 在app目录下添加了migrations 目录,目录下 0001_initial.py 记录了自动生成的db操作python代码 这时候,db还没有操作 已经存在app的话 一 ./manage.py convert_to_south myapp ...
今天刚买的阿里云主机 基本按 http://yubosun.akcms.com/tech/snmpd-ubuntu.htm 注释掉 defaultMonitors          yes 把 #agentAddress udp:161,udp6:[::1]:161 改成 agentAddress udp:161 原因 阿里云禁止了ip6?
1 sudo adduser jay 2 sudo visudo # User privilege specification root ALL=(ALL:ALL) ALL jay ALL=(ALL:ALL) ALL 3 sudo  vim /etc/ssh/sshd_config PasswordAuthentication yes
开发时: 1、static file 放在个各个app文件夹的static目录下 以及 settings.py中设置的S TATICFILES_DIRS; 2、 settings.py中的STATIC_ROOT 用不到的; [u]3、在urls.py 加入: if settings.DEBUG == True: from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns += staticfiles_urlpatterns() [/u] 这部在1.4 不用了 生产环境下 ...

mongodb 学习 tip3

    博客分类:
  • db
q:怎么插入纪录确定唯一性? 1 ensure index 2 insert(.. save=True) http://stackoverflow.com/questions/1352671/unique-ids-with-mongodb q: mdb.status.find().sort([('updated_at', pymongo.DESCENDING),]):

bootstrap tips

    博客分类:
  • web
针对2.0 1 navbar (导航条) 2种:navbar-fixed-top  or not 2
一 https://github.com/andreisavu/mongodb-log 该module包括: 1 一个python loggin的handler 2 web.py 的简单远程ui (如下图) 二 用 盛大云 mongoic 做 测试 uri = 'mongodb://user:password@mongoc2.grandcloud.cn:10004/db' 三 http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart /static/js/jquery-ui-1.7.2.custom.min.js 四 p ...

django logging

https://docs.djangoproject.com/en/1.3/topics/logging/ http://www.djangocurrent.com/2011/06/django-logging-quickstart-in-django-13.html
用来调试,阻塞、单线程 import SocketServer class EchoRequestHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) print data print '='*30 self.request.send(data) return import socket address = ('localhost', 8000) ser ...
dell 2850 http://tradearchive.taobao.com/trade/detail/tradeSnap.htm?tradeID=84536591331992 ======================================================================== BYTE UNIX Benchmarks (Version 5.1.3) System: jaylabsever2: GNU/Linux OS: GNU/Linux -- 2.6.32-36-generic-pae -- #79-Ubun ...
Global site tag (gtag.js) - Google Analytics