One, install the package and create the project
$sudo pip Install Django
$sudo python-c "Import Django;print Django. VERSION "
(1, 7, 0, ' final ', 0)
$sudo Django-admin Startproject CMDB #创建项目
$sudo Django-admin Startapp CMDB #创建应用
Second, modify the configuration
1. Modify settings.py, add CMDB application, and other settings
Installed_apps = (
' Django.contrib.admin ',
' Django.contrib.auth ',
' Django.contrib.contenttypes ',
' Django.contrib.sessions ',
' Django.contrib.messages ',
' Django.contrib.staticfiles ',
' CMDB ',
)
DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' CMDB ',
' USER ': ' CMDB ',
' PASSWORD ': ' CMDB ',
' HOST ': ' localhost ',
' PORT ': ' 3306 ', (www.111cn.net)
}
}
Language_code = ' ZH-CN '
Time_zone = ' Asia/shanghai '
2. Modify urls.py and views.py
urls.py content is as follows:
From Django.conf.urls import patterns, include, url
From Django.contrib Import admin
Urlpatterns = Patterns ("',
# Examples:
# URL (R ' ^$ ', ' cmdb.views.home ', name= ' home '),
# URL (R ' ^blog/', include (' Blog.urls ')),
URL (r ' ^admin/', include (Admin.site.urls)),
URL (r ' ^index/', ' Cmdb.views.index '),
)
views.py content is as follows:
From django.shortcuts Import Render
From django.http import HttpResponse
def index (req):
Return HttpResponse (' 3. Testing
Start Django
#sudo python manage.py runserver
Access:
Http://localhost:8000/index
From:http://www.111cn.net/sys/linux/67502.htm
Django Simple setup configuration steps under Mac