Python: Install django and create a project. pythondjango Project

Source: Internet
Author: User
Tags install django

Python: Install django and create a project. pythondjango Project

The example below is carried out in python2.7, And the python3.X operation is the same (and environment configuration can be omitted)

View pip version

Install django. "1.10.3" is the version number of django.

After successful installation, you will see the django_admin.exe file in the directory.

View django version

Configure Environment Variables

Add the python path and django path to the system environment variables respectively.

  • D: \ Python27
  • D: \ Python27 \ Lib \ site-packages \ django \ bin
  • D: \ Python27 \ Scripts

Enter the "django-admin" command in the windows Command Prompt and press enter to display the commands provided by django.

 

Create a folder, and then start creating a project. Run the startproject command.

After the creation, open NsDs. The following describes the directory (refer to the cainiao tutorial)

|-- NsDs| |-- __init__.py| |-- settings.py| |-- urls.py| |-- wsgi.py-- manage.py
  • Manage. py is a practical command line tool that allows you to interact with this Django project in various ways.
  • An empty NsDs/_ init _. py file tells Python that the directory is a Python package.
  • NsDs/settings. py the settings/configurations of this Django project.
  • NsDs/urls. py the Django project URL Declaration; a Django-driven website "directory ".
  • NsDs/wsgi. py a wsgi-compatible Web server portal to run your project.

View commands provided by manage

Start the service: run the runserver command. The default address is "127.0.0.1: 8000"

You can also specify the address

python manage.py runserver 127.0.0.1:8001

If the startup is successful, enter the address in the browser, as shown in:

Enter "127.0.0.1: 8000/admin" (admin is a built-in Background Management System of Django .)

 

 

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.