天天看點

Python + Django配置背景管理系統

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

  按提示輸入賬号密碼即可

  #python manage.py runserver

最新内容請見作者的GitHub頁:http://qaseven.github.io/