1. 打開 command line
2. cd 到要放code的資料夾
3. 執行 django-admin.py startproject mysitename
就會得到一個 mysitename 資料夾,內含
__init__.py
manage.py
settings.py
urls.py
這些檔案的用途
- __init__.py: An empty file that tells Python that this directory should be considered a Python package. (Read more about packages in the official Python docs if you're a Python beginner.)
- manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin.py and manage.py.
- settings.py: Settings/configuration for this Django project. Django settings will tell you all about how settings work.
- urls.py: The URL declarations for this Django project; a "table of contents" of your Django-powered site. You can read more about URLs in URL dispatcher.
激活管理介面(Admin Site)
1. 將"django.contrib.admin"加入settings.py中的INSTALLED_APPS。
2. 執行python manage.py syncdb 以更新database tables。
3. 編輯urls.py,將“Uncomment the next two lines...”下的comment符號(#)去掉並將(r'^admin/', include(admin.site.urls)),加到urlpatterns中
python manage.py startapp someappname
Note: http://code.djangoproject.com/ticket/10050
張貼留言