python Django framework installation and testing

What is Django:

There are many different web frameworks under Python. Django is the most representative of the heavyweights. Many successful websites and apps are based on Django.

Django is an open source web application framework written in Python.

Django complies with the BSD copyright and was first released in July 2005, and the first official version 1.0 was released in September 2008.

Django adopts the software design pattern of MVC, namely Model M, View V and Controller C.

Diango is also a very suitable framework for getting started with python. After learning the use of this framework, it is very easy to use other frameworks or develop other python aspects.

Django installation:

win+x to open the computer management interface, press a or select Command Prompt (Admin).

Use the pip command in the opened cmd window:
pip install django

After the installation is complete, the following words appear:

Collecting django
  Downloading Django-2.0.1-py3-none-any.whl (7.1MB)
    100% |████████████████████████████████| 7.1MB 81kB/s
Collecting pytz (from django)
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
    100% |████████████████████████████████| 512kB 936kB/s
Installing collected packages: pytz, django
Successfully installed django-2.0.1 pytz-2017.3

Django test:

Command line input:
python -m django version

Check the current django version,

Display:
2.0.1

This represents version 2.0.1.

So far.

In which path is the extension package we installed in the end?
If you are using a Windows system, you can find the downloaded third-party extension packages under the path: ...\python37\Lib\site-packages, and Linux is /usr/local/lib/python/dist-packages/.

==============================================================

ps:

Two commonly used dos commands are added here:

pip command:

This is a command used by Python to install python packages. It can be seen as a command tool brought by python for its own expansion. We installed django with python install django

Of course, if you want to uninstall the python package, just replace install with uninstall.

More detailed information can be viewed by simply typing pip at the command line.

python -m command:

When we use python to open the server, we use python -m (pyhon 2, python 3 are different, but both use -m), what does python -m mean here?
Enter python --help on the command line, and the introduction that comes with python will appear. We find -m:

-m mod : run library module as a script (terminates option list)

As you can see, this command runs the template in the library as a script.

The reason why we can open the server so simply is because python has already integrated the script for building the server into the python template, and our statement command is just to let the computer run this command.

If you have time, you can locate the python template library and take a look at its content.

Continue to add:

In some cases, -m can be used without -m, and the difference between -m and no -m is that the former is started as a module, while the latter is started directly, which is equivalent to importing packages (of course, direct startup will often fail to find to file).

Detailed introduction

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325440923&siteId=291194637