建立项目
django-admin.py startproject mysite
运行项目
python manage.py runserver
默认地址和端口:127.0.0.1:8000
startapp
python manage.py startapp addr_book
修改settings.py
# settings.py # INSTALLED_APPS = ( ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.sites‘, ‘addr_book‘, )
修改urls.py,注意$
from django.conf.urls.defaults import * urlpatterns = patterns(‘‘, (r‘^hello/$‘, addr_book.views.hello), )
设置模板地址,settings.py
TEMPLATE_DIRS = ( ‘./addr_book/‘, )
检查语法与逻辑错误
python manage.py validate
初始化数据库
python manage.py syncdb
时间: 2025-01-03 21:58:33