How to install pythonDjango

Source: Internet
Author: User
Tags django website install django
There are more and more web development languages. This article is about installing pythonDjango. after reading this article, you can use PYTHON for development. Installation environment: python version 2.7.5 and win7
Install Django
Https://www.djangoproject.com/download/ official download django-1.5.5.tar.gz
1, unzip (my directory is D: \ myapp \ Django-1.5.5)
2. execute the command python setup. py install under the unzipped Django-1.5.5 Directory. The result is as follows:


Note: The Django installation command actually copies Django to the local Python installation directory D: \ Python27 \ Lib \ site-packages.
Test Django installation
# Vim: set fileencoding = UTF-8: # Test Django installation import djangoprint django. VERSION

The output is as follows:


Start a project
1. run the doscommand to a directory (where do you want to create a project, for example, E: \ workspace \ pythonworkspace ).
2, django-admin.py startproject MyDjangoSite (MyDjangoSite your project name)
Note: 1. before executing this command, add D: \ Python27 \ Lib \ site-packages \ django \ bin to the value environment variable path.
2.pythonfilepaper the program is python.exe. Otherwise, the django-admin.py file is opened after the program is executed. (This problem occurred for a long time before I found that the python file is opened by default in vim. as a result, the file directory is not generated in this directory after executing the Create project command)
3. File description:
Manage. py: a command line tool that allows you to interact with this Django project in multiple ways. Type python manage. py help to see what it can do. You should not need to edit this file; generate it in this directory for convenience. _ Init _. py: let Python treat this directory as a file required by an development kit (that is, a group of modules. This is an empty file. you do not need to modify it. Settings. py: settings or configurations of this Django project. View and understand the available setting types and their default values in this file. Urls. py: Set the URL of the Django project. It can be viewed as the Directory of your django website. Currently, it is empty.
Wsgi. py: An entry-point for WSGI-compatible webservers to serve your project. See How to deploy with WSGI for more details.
Detailed usage reference document https://docs.djangoproject.com/en/1.4/intro/tutorial01/
Run the development server test
The django development service is a built-in, lightweight web service that is available during development. We provide this server to allow you to quickly develop the site. that is to say, you do not need to configure the product-level Web server (such as Apache) before preparing to release the product. The development server monitors your code and automatically loads it, so that you can easily modify the code without restarting the service.
Run the DOS command to go to the created project and run python manage. py runserver, for example:


Browser http: // 127.0.0.1: 8000 test



The test is successful. The python Django web development environment is now available.

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.