1. 建立project
django-admin.py startproject newproject
完成上个步骤后,可发现在newproject文件夹下生成了:一个名为newproject的文件夹,一个manage.py文件。
newproject文件夹上又包含了4个文件:
__init__.py
setting.py
urls.py
wsgi.py
至此project建立完毕!
2. 修改文件
#vim urls.py
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'csvt01.views.home', name='home'),
# url(r'^csvt01/', include('csvt01.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
去掉标红位置的#
#vim setting
INSTALLED_APPS中去掉‘django.contrib.admin’这行的注释
另外配置数据库
3.创建数据库表
#python manage.py syncdb
按提示输入账号密码即可
4.开启测试服务
#python manage.py runserver