python

get_template()でUnicodeDecodeError

ファイルの文字コードをutf-8にしてで保存する http://stackoverflow.com/questions/11072478/python-unicodedecodeerror-utf8-codec-cant-decode-byte-unexpected-code-byt http://advweb.seesaa.net/article/3074705.html

pythonスクリプトからExcelファイルを開く

os.system('start excel.exe %s' % (path, )) subprocess.call(['start', 'excel.exe', path], shell=True) http://stackoverflow.com/questions/13720940/opening-running-excel-file-from-python http://ja.pymotw.com/2/subprocess/

リスト内包表記

http://www.lifewithpython.com/2014/09/python-list-comprehension-and-generator-expression-and-dict-comprehension.html

リストの重複を削除

http://d.hatena.ne.jp/aroma_black/20110203/1296746826

AppRegistryNotReady: Models aren't loaded yet.

objects.all().delete()でエラー C:\Users\shohaya\tf-manager\tfmanager\db>python initteam.py Traceback (most recent call last): File "initteam.py", line 60, in init_team() File "initteam.py", line 49, in init_team obj.delete() File "C:\Anaco…

settings読み込みエラー

django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 環境変数…

pythonからodbcでSQL Serverに接続

http://bluestick.jp/tech/index.php/archives/215

django1.7新機能migrations

http://a-records.info/2014/09/29/18/

django.db.utils.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server Native Client 10.0}, 6): image not found (0) (SQLDriverConnect)')

~/TFManager/tfmanager $ python manage.py migrate --list Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/Users/shohayakawa/anaconda/lib/python2.7/site-packages/django/core/manageme…

ERROR IM002 Microsoft ODBC Driver Manager

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in SSRS odbcのエラー settings.pyで指定しているODBCの名前が違うことによるエラーだった。 あとSQL Server Expressをインストールしていない…

django-pyodbc-azureをインストール

$ sudo pip install django-pyodbc-azure Password: Requirement already satisfied (use --upgrade to upgrade): django-pyodbc-azure in /Users/shohayakawa/anaconda/lib/python2.7/site-packages Downloading/unpacking Django>=1.7.1 (from django-pyod…

pipでpyodbcをインストール

pip install pyodbc これだと Could not find any downloads that satisfy the requirement pyodbc と言われる sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc とするとインストールできた。 http://stackoverflow.com/questio…

pipでpyodbcインストール時にエラー

n file included from /private/tmp/pip_build_root/pyodbc/src/buffer.cpp:12: /private/tmp/pip_build_root/pyodbc/src/pyodbc.h:52:10: fatal error: 'sql.h' file not found #include sql.h ^ 1 error generated. error: command 'gcc' failed with exit…

PythonでMySQLに接続

http://www.python-izm.com/contents/external/mysql.shtml

DjangoでDBにテーブル追加

①Modelにクラス追加 ②makemigrations python manage.py makemigrations ③migrate python manage.py migrate

attributeerror user has been swapped

AttributeError: Manager isn't available; User has been swapped for 'login.User' http://stackoverflow.com/questions/17873855/manager-isnt-available-user-has-been-swapped-for-pet-person

python オブジェクトの属性を調べる

print dir(obj) オブジェクトの持つ属性をprint