Django Simple setup configuration steps under Mac

Source: Internet
Author: User
Tags install django pip install django

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.