Create a project with Django

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

First you have to install Python and Django, then configure the environment variables, install Python, and start with the configuration environment variable.

1. Configure Environment variables

Right-click on my Computer, or open Control Panel \ System and Security \ System

Left navigation bar, advanced system settings, environment variables--and then you'll see the following interface

  

Click this path and click Edit

Then find the C:\Python27 folder and add this folder.

2. Install Django

Open cmd, execute pip install Django or

This package is downloaded and then unpacked and then opened, is this

  

--Open cmd, open this folder, execute Python setup.py install

Just wait.

3. Verify that Django is installed successfully

Import Django

If this sentence does not error, then there is no problem.

4. Configure the Django environment to change quality.

Or do you open the path in the environment variable as you just did? This time, the paths added are:

5. Create a project with Django

Open cmd and enter your workspace to execute the command:

  

If you see the following,

This may be caused by a version issue that you can perform

If there is no hint, it is successful. If also reported is wrong, it has to be checked.

After successful execution, in your workspace directory there will be two layers of website folder, into the two-tier website folder, there will be the following several files

  

6. Create Djangoapp

Enter website directory, execute admin.py Startapp blog or admin Startapp blog

There is still no hint, this time in your website directory is a more blog folder, and a sqlite3 database.

7. modifying urls.py and views.py

Open views.py to add the test code as follows:

  

In fact, a function is defined and a string is returned.

Open urls.py, add a Word url (r ' ^blog/index/$ ', blog.views.index,name= ' index ')

    

8. Turn on the server

Run the command in the website directory

Or manage.py Runserver, the version is not the same cause

If you see the following interface, it means that the server is open successfully.

  

You can open the browser and enter

This address to view the results.

Create a project with Django

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.