Django environment construction in Windows environment
The premise is that python and mysql have been installed on the Windows machine
First we download these files: python-mysql, django
mysql-python is an executable file, install it directly.
1. Install django
Now we need to install django. Extract the downloaded compressed package to any directory:
Extract django to any directory
Open the command prompt (cmd), enter the directory. And type the command shown in the picture below:
python setup.py install
After pressing Enter, you will see the process of Django being installed. After completion, you can delete the decompressed directory.
2. Set the Django environment variable:
In this way, we have Django installed.
Test
Setting up the environment and doing nothing actually doesn’t bring much sense of accomplishment. Now let’s have a sense of accomplishment and create a new project with django and run it:
First we open cmd and navigate to the directory where we want to create a new project, any directory Either way. Then type the following command:
django-admin.py startproject hello
where hello is the file name of the new project directory. After confirming the execution, django will create a new project for us. The hello folder contains django framework related files and Default configuration file. We don’t care about its details first.
Next we locate the path of cmd to the hello directory. And execute the following command:
python manage.py runserver
Django server is successfully started
Open the browser and visit: http ://127.0.0.1:8000/ . Try it quickly and see what happens.
Be sure to note here: this server is only a lightweight server built into Django for testing and cannot be used in a production environment.