Django combat (1) - Creating your first Django project

What is Django?

Django is a high-level open-source model-driven programming language Python, View, Controller-style Web application framework, which originated in the open source community. Using this framework, programmers can quickly and easily create high-quality, easy maintenance, database-driven applications. Django project from an online news Web site, in 2005, was released as open source. The core components of the Django framework are:

  • Object-relational mapping is used to create the model;
  • Well-designed management interface for end users;
  • URL design;
  • Designer-friendly template language;
  • Caching system.

Installing Python

Before using Django you have to install Python, if not installed friends can look at this article to install and configure the environment Python, pycharm installation and configuration of Python , this article has described in detail how to install and configure, not explained in detail here , and quickly loaded from the

Install Django

After installing the Python environment is to install Django, open cmd enter the following command to install Django

pip install django

As the author is already installed, so I can not say here in detail

First, create a first Django project

After Django Python environment and are ready we can create a Django project on the
top left, click File - New Project
Here Insert Picture Description
will pop up the following interface according to the above operation is performed, which

  • Location: represents the path where your project + project name (here assumed to be mysite)
  • Existing Interpreter: indicate existing Python environment, if not checked, will automatically download the Python environment and Django (trouble)
    Other options are the default, and then click Create to create
    Here Insert Picture Description
    the following is a block diagram mysite project we created
    Here Insert Picture Description
    on the drawing we file one by one to talk about:
  • _ The init _.py: to make the directory as a Python development package (ie a set of modules) files required. This is an empty file, generally we do not need to modify it
  • settings.py: Set the Django project, or a configuration, is to see and understand the document types available and set its default value
  • urls.py: Indicates that the URL setting Django project, it can be seen as the directory of your Django site
  • manage.py: a command-line tool that allows you to interact in various ways with the Django project, type

Do not underestimate these documents, these documents sufficient to constitute a Django application that can be run, and refused to accept? All against tyranny
Here Insert Picture Description
optimistic about what the code did not write, just click the Run
Here Insert Picture Description
command when running normally click on the default console input is manage.py runserver 8000, if the command is entered directly in the console will have to add in front python on the field, namely:

python manage.py runserver 8000

If you want to change other port access as is possible, you want to change the 8000 port can be
OK, we start the Django project not access it, we visit it to see http://127.0.0.1:8000/ under what appears stuff

Here Insert Picture Description
Amazing it, what code did not write, but simply to create a project can run and can be visited? Incredible, and you can see from the top right corner of Django I'm using version 2.1 of

Published 184 original articles · won praise 864 · views 110 000 +

Guess you like

Origin blog.csdn.net/Woo_home/article/details/103704925