ï¼»è¨æ£ï¼½ãã¡ã¤ã«ã®ã¨ã³ã³ã¼ãã£ã³ã°ã¨æ¹è¡ã¿ã¤ãã追å
ジャンゴと奏でる 〜数時間でおぼえるDjango〜「もくじ」
Webãã©ã¦ã¶ã®ç¢ºèªç°å¢ã追å ãè¥å¹²ä¿®æ£
ã¾ããã
ãã®ãã¥ã¼ããªã¢ã«ã¯ãæ軽ã«Djangoã«è§¦ãã¦ã¿ããè¶
åå¿è
åãã«æ¸ãã¾ãããã試ãç¨åº¦ã«ä½æ¥ããããããªãããããã¤ã¹ãã¼ãã»ã¢ãã©ã¯ã·ã§ã³çãªãã¥ã¼ããªã¢ã«ãç®æãã¦ã¾ããã ããç´°ãã説æã¯ãªãã¹ãçãã¦ãã¾ãã詳細ãç¥ããããªã£ãã公式ドキュメントï¼和訳ï¼ãªã©ãåç
§ãã¦ãã ããã
Djangoã¯Pythonã®Webãã¬ã¼ã ã¯ã¼ã¯ã§ãããPythonã®ç¥èãã¾ã£ããç¡ãã¦ããã®ãã¥ã¼ããªã¢ã«ç¨åº¦ã§ã¯åé¡ãªãã¨æããã¾ãã
ãããæ©ä¼ã«ãå¤ãã®äººã«Djangoã好ãã«ãªã£ã¦ãããããå¬ããã§ã(ã»âã»)
ï¼ããããããã³ãæè¿ã諸äºæ
ã«ããWebãã©ã¦ã¶ã§ã®ç¢ºèªã¯FireFox2ï¼MacOSX10.4ï¼ã®ã¿ã§è¡ã£ã¦ãã¾ããï¼
ã³ããæ¨å¥¨
æ®éã¯ã³ããããã«èªåã®æã§å ¥åãããã¨ãè¦ãããã©ããã®ãã¥ã¼ããªã¢ã«ã§ã¯æåã«ã³ããã§ä¸éããã£ã¦ã¿ã¦ããã次ã«æå ¥åã§è©³ç´°ãè¦ãªããé²ãããããªå¦ç¿æ¹æ³ãè¦ãã¾ããä½åãç¹°ãè¿ããã¨ã§ç解ãé«ã¾ãã¨æããããããã«ãã¥ã¼ããªã¢ã«ã®ä¸ã«ã¯ããã®éããã£ã¦ãåããªããã¨ããããããã ããåä½æ¤è¨¼ãããã¦ã³ããæ¨å¥¨ã
æºå
Python2.5 laterãDjango1.0 laterãSQLite3ã®ã¤ã³ã¹ãã¼ã«ãªã©æºåã¯åºæ¥ã¦ãã¾ããï¼
ï¼æºåã§ãã¦ãªã人ã¯ãã¡ããåç
§ãã¦ã¿ã¦ãã ãã「00インストールと開発環境」ï¼
ããã§ã¯Djangoã§è£½ä½éå§ãã¾ãã
ãã¡ã¤ã«ã®ã¨ã³ã³ã¼ãã£ã³ã°ã¨æ¹è¡ã¿ã¤ã
ãã®ãã¥ã¼ããªã¢ã«ã§æ¸ãPythonãhtmlãªã©ãã¡ã¤ã«ã®ã¨ã³ã³ã¼ãã£ã³ã°ã¯ãUTF-8ããæ¹è¡ã¿ã¤ãã¯ãLFãã«ãã¦ãã ããã
ããã¸ã§ã¯ããä½æ
Djangoã®ããã¸ã§ã¯ããä½æãã¾ãã
ã¨ããããã³ã¼ããç½®ãå ´æã¨ãã¦ãhogeããã£ã¬ã¯ããªãä½ããããã«ãstartprojectãã³ãã³ãã§ãjamãã¨ããåã®ããã¸ã§ã¯ããä½æãã¾ãã
以ä¸ã³ãã³ãã©ã¤ã³ããå®è¡ãã¦ãã ããã
$ mkdir hoge $ cd hoge /hoge $ django-admin.py startproject jam
ãjamããã£ã¬ã¯ããªãä½ããããã®ä¸ã«ï¼ã¤ã®ãã¡ã¤ã«ãä½ããã¾ãã
/hoge $ cd jam /hoge/jam $ ls __init__.py manage.py settings.py urls.py
setting.pyã§è¨å®ï¼å¤æ´ç®æããããæç²ï¼
/hoge/jam/settings.pyã®å 容ãæ¸ãæãã¦Djangoã®è¨å®ããã¾ãã
ã¾ãå é ã«ãã¹ã®è¨å®ããã¦ããã¾ãã
# Django settings for jam project. import os BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ãã¼ã¿ãã¼ã¹ï¼ãã®ãã¥ã¼ããªã¢ã«ã§ã¯SQLite3ã使ãã¾ãï¼
DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = os.path.join(BASE_DIR,'sqlitedatabase.db')
æé
TIME_ZONE = 'Asia/Tokyo'
è¨èª
LANGUAGE_CODE = 'ja'
CSSãç»åãªã©éçãã¡ã¤ã«ã®ç½®ãå ´æãæå®
MEDIA_URL = '/static/'
ãã³ãã¬ã¼ãã®ç½®ãå ´æãæå®
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
Djangoã§å©ç¨ããã¢ããªã±ã¼ã·ã§ã³
ï¼'django.contrib.admin'ã¯ç®¡çç»é¢ã'jam.entries'ã¯ããããä½ãã¢ããªãä»ã®ï¼ã¤ã¯ããã©ã«ãï¼
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'jam.entries', )
ã¨ããããè¨å®å®äºã§ãã