Python Learning Series (2) install Django in Windows8.1

Source: Internet
Author: User
Tags install django

1. Download
Download https://www.djangoproject.com/download/latest version. The latest version is 1.6.


Ii. installation:
Decompress the downloaded django-1.6.tar.gz file to drive D. Then run win + X command prompt to go To the Django directory of drive D and run the setup. py install command to execute the installation.

After the installation, we found that Django was installed in the Directory D: \ Python33 \ Lib \ site-packages \ django. There is a bin subdirectory in this directory, which stores common Django commands. To facilitate future operations, we need to add this bin Path to the operating system environment variable Path. Add the Django command path "; D: \ Python33 \ Lib \ site-packages \ django \ bin ".

So far, we have completed the installation of Django. Next we need to verify whether we can start working. First, open a CMD command window to check whether the Common commands of Django can be used. Then, let's see if Django has been integrated with the python environment.

From this, we first run django-admin.py -- version at the operating system prompt, and the system prints the Django version 1.6 ". Enter "Python" to enter the python runtime environment. At the ">>>" prompt, enter a python module import Statement "import django ", this statement indicates that the "django" function module is introduced in the current python runtime environment. Then, we use the "VERSION" method of this function module to view the VERSION number of this module, we also see the same version number. If you see the complete information on your computer, then OK, which proves that your computer can start to execute python programs based on the Django system.

3. Create a Django Project
First enter the F disk, enter the command django-admin.py startproject mysite to create a website project, the website directory name is mysite, path is F: \ mysite. Go to the mysite directory and enter manage. py runserver to open the website. You can specify a port. The default value is 8000. To use port 90, write it as manage. py runserver 90.
 
Finally, open the browser and enter the address http: // localhost: 8000 in the address bar. If "It worked" is displayed, the configuration is successful.
Next we will create a Hello world page:
With Django, the page content is generated by view functions. We create a View File views. py in the F: \ mysite directory and enter the following content:

  django.http         HttpResponse()



Next, modify the URL. py file under the mysite directory. The content is as follows:

   django.conf.urls    mysite.views    urlpatterns = patterns(       ( )
 
Finally, open the browser and enter the address http: // localhost: 8000/hello/in the address bar. If the result is displayed, it means the operation is successful.

Note:Views. py must be placed in the mysite directory at the same level as urls. py. Otherwise, an error will occur and the directory structure is attached.

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.