返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
0_Python-Web-Django入门系列笔记

Python-Web-Django: Starting the Django Journey

Preface The open-source web framework Django is simple and easy to use, with high stability and flexibility, so it is widely used in commercial environments. It fully leverages Python's advantage of having a rich set of libraries. Installing Django and Setting Up the Server Install the Django library: pip install django Create a new web application: django-admin startproject hello_django The above command will create a hello_django directory in the current folder. The directory structure is as follows

曦远 (DealiAxy)约 6 分钟
目录6 个章节

Preface

The open-source web framework Django is simple and easy to use, with high stability and flexibility, so it is widely used in commercial environments. It fully leverages Python's advantage of having a rich set of libraries.

Installing Django and Setting Up the Server

Install the Django library:

pip install django

Create a new web application:

django-admin startproject hello_django

The above command will create a hello_django directory in the current folder. The directory structure is as follows:

  • hello_django
    • manage.py
    • hello_django
      • __init__.py
      • settings.py
      • urls.py
      • wsgi.py

File descriptions: settings.py: Stores all parameter settings for the server urls.py: Collects all URL paths of the web application and the corresponding function names. These functions are located in views.py; their role is to render templates and generate the web pages pointed to by the URLs wsgi.py: The module for server communication with the web application

Starting the Server

python manage.py runserver 8080

Open a browser and enter 127.0.0.1:8080. If you see the following interface, it means the server has started successfully.

Creating an App

Now our server still doesn't have anything. For the web server to actually function, we need to create different Web Apps. Use the following command to create an App:

python manage.py startapp hello_app

This command will automatically create a hello_app directory under the server directory (hello_django). The directory structure of hello_app is as follows:

  • hello_app
    • __init__.py
    • admin.py
    • apps.py
    • models.py
    • tests.py
    • views.py
    • migrations
      • __init__.py

The configuration of settings.py will be introduced in the next article.

About

To learn more interesting operations, please follow my WeChat official account: DealiAxy Every article is collected on my blog: blog.deali.cn

_EOF_

Python-Web-Django: Starting the Django Journey

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…