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