原创 redis test
install sudo pip install redis set, get import redis r = redis.Redis(host='localhost', port=6379, db=0) r.set('key1
原创 django modeladmin override ModelForm
定製admin site中與Model對應的form表單中的Field stackoverflow
原创 tango with django ch12
User Authentication install Django-Registration-Redux sudo pip install django-registration-redux 修改installed_apps I
原创 nginx start error
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use) nginx -s stop nginx curl http://localhost
原创 django admin site override save_model
檢查一個field是否變化了http://stackoverflow.com/questions/8056179/django-admin-save-model-method-how-to-detect-if-a-field-ha
原创 Python datetime compare
比較當前時間與數據庫中的時間 在數據庫中日期字段是的utc的。所以獲取到當前時間後,需轉化爲utc的。 import pytz from datetiem import datetime now = datetime.now(py
原创 django migrate error: table 'xxx' already exists
python manage.py migrate --fake <appname> 參考:http://stackoverflow.com/questions/25924858/django-1-7-migrate-gets-er
原创 Python Hidden Features
http://stackoverflow.com/questions/101268/hidden-features-of-python#111970
原创 Django 請求處理過程
How Django process a request Django決定使用root URLconf模塊。即項目名.urls Django 加載1中Python模塊,尋找urlpattens變量.urlpatterns變量是d
原创 python datetime module
data types datetime.date: 理想化的日期,公曆 datetime.time: 獨立的時間, 假定每天都有24*60*60秒。 datetime.datetime: date和time的組合,屬性有:
原创 python 異步IO
pass
原创 Head first 設計模式_筆記
一切模式的基礎 將變化的部分與應用的其他部分分割開來。
原创 Python error collections
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe5 in position 0: ordinal not in range(128) 再將一段包含漢子的字符串寫入csv
原创 django fields lookup methods
參考https://docs.djangoproject.com/en/1.9/ref/models/querysets/#field-lookups 基本長這樣:field__lookuptype=value lt 小於, lt
原创 Python Challenge
0.html print 2**38 map.html k->m, o->q e->g # Python Challenge # http://www.pythonchallenge.com/pc/def/map.html st