Django installation and start, Django installation and start

Source: Internet
Author: User
Tags install django

Django installation and start, Django installation and start

1. Install django

Download the latest website of djangoon http://www.djangoproject.com/download. When downloading, make sure that the django version matches the Python version installed on the local machine. In this example.

After the download, decompress the package and install it. The specific installation command is as follows:

 

Tar xzvf Django-1.9.1.tar.gz

Cd Django-1.9.1

Sudo python setup. py install

2. Test django Installation

After installing django, first test whether django is successfully installed. Open the Python notebook and enter the following command:

>>> import django  >>> django.VERSION  (1, 9, 1, 'final', 0)  

  

You can get the installed django version to prove that django has been installed successfully.

3. Start a project

Create a directory, and then create a django project under the directory. The command is as follows:

Mkdir djangocode

Cd djangocode/

Django-admin.py startproject mysite

In this way, a mysite directory is created under the current directory. The directory structure is as follows:

Mysite/

Manage. py

Mysite/

_ Init _. py

Settings. py

Urls. py

Wsgi. py

Manage. py: a command line tool that allows you to interact with this django project in multiple ways.

_ Init _. py: Let Python treat this directory as a file required by the Development Kit.

Settings. py: configuration file of this django project.

Urls. py: the URL setting file of the django project.

Wsgi. py: wsgi is a simple and common interface between a web server defined in the Python language and a web service program or framework.

4. Run the django Service

Run the following command to start the django service:

Python manage. py runserver

By default, a local server is started on port 8000. Visit http: // 127.0.0.1: 8000/in the browser on the local machine. A django welcome page is displayed, indicating that the server is successfully started.

If you want other computers to access this page, run the following command:

Python manage. py runserver 0.0.0.0: 8000

The IP address 0.0.0.0 tells the server to listen for any network interface. In this way, other computers in the local network can access the page through the Server IP address in the browser.

 

Related Article

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.