Django is simplyuse
Free Open SourceWeb Framework
Using Django enables you to build and maintain high-quality Web applications at minimal cost.
linux（ubuntu） + python3.6 + pycham + mysql
First, create a virtual environment in the virtual machine.
mkvirtualenv -p /usr/bin/python3 django_test
Install the Django we need (I chose Django version 2.1.0)
pip install django==2.1.0
New project django_test
django-admin startproject django_test
Then check it out.
There’s an additional django_test folder. Let’s take a look at the structure of this file.
- Manage.py: A command-line tool in Django for managing Django projects
- _ init_.py: Empty file, tell python that this directory is a python package
- Set.py: Configuration file, including database information, debug flags, static files, etc.
- Urls.py: URL declarations in Django projects
- Wsgi.py: Used for deploying servers
Next, synchronize pycham
Connect the virtual connection interpreter, fill in the information, and click Next
Enter your password and click Next
Find the interpreter location
Directories in the corresponding virtual machine
After clicking ok, you can synchronize the project you just created in the virtual machine to the local location.
Configure native Django settings
Set ALLOWED_HOSTS=  in set.py to ALLOWED_HOSTS= [‘*’]
Open Server 1
Enter the django_test file in the virtual machine and enter it again
python manage.py runserver 0.0.0.0:8000
Local browser input 127.0.0.1:8000
Then we can see a small rocket!
Open Server 2
Set to 0.0.0.0
Re-enter settings to set Django
Click ok, Django is set
After clicking on the green triangle to start, you can see the small rocket by typing 127.0.0.1:8000 into the browser.
Now let’s start creating view functions
Create a view.py file in the project directory (request is required)
Add routing to urls.py
Then go to the browser and enter 127.0.0.1:8000/index/
So we got our first page.
Then we created the first app:book for our project.
Method 1: You can enter it from the virtual machine command line
python manage.py startapp book
Method 2: Click here in pycham
Enter startapp book
Synchronize the directory and you’ll have our book app.
At this point, our first stop in learning Django is over.