Xiaobai Learning Django First Station-Environment Configuration


Django is simplyusePythonDeveloped oneFree Open SourceWeb Framework

Using Django enables you to build and maintain high-quality Web applications at minimal cost.

Open up!!!

Tool preparation:

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

New projects

click here

Connect the virtual connection interpreter, fill in the information, and click Next

Enter your password and click Next

Find the interpreter location

Click Create


Upload Settings

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

Local browser input

Then we can see a small rocket!

Open Server 2

click here

Set to

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 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

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.

Recommended Today

Hadoop MapReduce Spark Configuration Item

Scope of application The configuration items covered in this article are mainly for Hadoop 2.x and Spark 2.x. MapReduce Official documents https://hadoop.apache.org/doc…Lower left corner: mapred-default.xml Examples of configuration items name value description mapreduce.job.reduce.slowstart.completedmaps 0.05 Resource requests for Reduce Task will not be made until the percentage of Map Task completed reaches that value. mapreduce.output.fileoutputformat.compress false […]