virtualenv Description : virtualenv is an independent (relatively) development environment gave us as a development environment for us to operate. In this way, we can start on the same computer multiple versions of Django development, but also do not have to worry about confusing versions, and you can clearly see our installed packages, packages.
Installation virtualenv environment : Enter the command linepip install virtualenv
Create a virtual development environment :
First, create a new folder as the project directory
holding down the shift key, right-click the file in the folder, select Open Command Window Here
the process of creating command python -m venv djangoProject
(djangoProject virtual environment name)
If this error appears you can use python -m venv --without pip djangoProject
such a virtual Python to built environment
Start the virtual environment with Django installation :
Under running a virtual environment in cmd (file folder you created in the previous step) of activate.bat files in the script directory to start the virtual environment
such virtual environment will be started
we can also use the command to exit the virtual environment
to run in a virtual environment among cmd deactivate.bat script files in the directory to exit the virtual environment
to start a virtual environment, and then install Django framework in a virtual environment which
enter the command line in a virtual environment pip install django
so Django our virtual environment is now installed
Create a Django project and configuration environment variable :
Create a Project command django-admin startproject School
(Note: School project name)
Note: this command is executed where it will create a project in which path
so that we create a Django project
Next we use pycharm open the project
the next configuration environment variables (the environment variable environment variables to configure our virtual environment)
to enter the settings pycharm, click on "project: project name" project Interpreter click
the gear icon, click the red circle, select Add Local
selected python.exe in our virtual environment
click OK
and then use our newly added environment variables
see no dj icon on the red cross to show that our environment variable configuration was successful
Python Django project document presents :
writing a simple Django project (hello world!):
Create a view file: directory described above is to create a built-in directory of the project, in order to achieve today's program, but you need to create a file called views.py in School \ School own
writing web logic:
write in the following views.py Code
to add the following code to the project document routing
startup items:
click the green triangle button in the upper right corner pycharm
Viewed through a browser program impact:
in the browser address bar http://127.0.0.1:8000/index/
to access
a simple Django project is successful