Install and configure django on Mac

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

Install and configure django on Mac

1. install the software package and create a project

$ Sudo pip install django
$ Sudo python-c "import django; print django. VERSION"
(1, 7, 0, 'final', 0)
$ Sudo django-admin startproject cmdb # create a project
$ Sudo django-admin startapp cmdb # create an application
Ii. modify configurations

1. Modify settings. py to add the cmdb application and other settings.

INSTALLED_APPS = (
'Django. contrib. admin ',
'Django. contrib. auth ',
'Django. contrib. contenttypes ',
'Django. contrib. session ',
'Django. contrib. messages ',
'Django. contrib. staticfiles ',
'Cmdb ',
)
DATABASES = {
'Default ':{
'Engine': 'django. db. backends. mysql ',
'Name': 'cmdb ',
'User': 'cmdb ',
'Password': 'cmdb ',
'Host': 'localhost ',
'Port': '123', (www.111cn.net)
}
}
Export age_code = 'zh-cn'
TIME_ZONE = 'Asia/Shanghai'
2. Modify urls. py and views. py.

The contents of urls. py are 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 '),
)
The contents of views. py are as follows:

From django. shortcuts import render
From django. http import HttpResponse
Def index (req ):
Return HttpResponse ('3. Test

Start django


# Sudo python manage. py runserver
Access:

Http: // localhost: 8000/index
From: http://www.111cn.net/sys/linux/67502.htm


How does one install Django on Mac OS? Detailed installation steps and instructions. The online tutorials are complex and hard to understand!

Download the django Installation File, decompress it, and run the command line cd to the directory of the extracted file. Execute python setup. py install.

When installing Django on Mac, you must first install Distribute and PIP. What are the differences between Distribute and PIP?

Both Distribute and PIP are python installation package tools. The python installation package tools include easy_install, setuptools, pip, and distribute.
You can use these tools to download and install django.

Distrils is an enhancement to the standard library's disutils module. We know that disutils is mainly used for easier packaging and distribution of packages, especially for packages that are dependent on other packages.

Install Distribute
You can install distribute_setup.py through the distribute_setup.py script, or install distribute_install, pip, or the source file. However, using distribute_setup.py is the simplest and most popular method

Pip is a tool for installing python packages. It provides the installation package to list installed packages, upgrade packages, and uninstall packages.
Pip is a replacement of easy_install and provides the same search Package function as easy_install. Therefore, you can use the package installed by easy_install or pip for installation.

Install Pip
You can use the source code package, easy_install, or script to install Pip.

Easy_install:

$ Easy_install pip
OK. Let's take a look at Pip usage.
Install package

$ Pip install Markdown
List Installed packages

$ Pip freeze
Install a package of a specific version
You can specify a version number by using ==,>=, <=, >,<.

$ Pip install 'markdown <2.0'

$ Pip install 'markdown> 2.0, <2.0.3'
Upgrade package
Upgrade the package to the latest version. You can use-U or -- upgrade

$ Pip install-U Markdown
Uninstall package

$ Pip uninstall Markdown
Query package

Pip search "Markdown"

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.