GithubHelp home page GithubHelp logo

django-demo's Introduction

关于 Django 项目

安装 Python

安装 Django

pip install Django

查看 Django 版本

python3 -m django --version

创建 django 项目

django-admin startproject siteName

python -m manage.py startapp poll

新建 django 项目目录结构

/*
    siteName-----------------django项目根目录,不会影响django项目
        manage.py------------命令行工具,用于django项目交互<vhttps://docs.djangoproject.com/en/3.2/ref/django-admin/>
        siteName-------------项目真正的python包目录
            __init__.py------告诉python,当前目录是一个python包
            settings.py------django项目配置文件<https://docs.djangoproject.com/en/3.2/topics/settings/>
            urls.py----------django项目的URL声明文件<https://docs.djangoproject.com/en/3.2/topics/http/urls/>
            asgi.py----------An entry-point for ASGI-compatible web servers to serve your project<https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/>
            wsgi.py----------An entry-point for WSGI-compatible web servers to serve your project<https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/>
 */

启动 Python 服务

python3 manage.py runserver

指定端口:python3 manage.py runserver 8080

python manage.py migrate

Django 中的 projects 和 app

An app is a Web application that does something – e.g., a Weblog system, a database of public records or a small poll app. A project is a collection of configuration and apps for a particular website. A project can contain multiple apps. An app can be in multiple projects.

projects 就是环境,整个项目以及 Django 的基础配置,可以理解为就是 siteName

创建 Django App:python manage.py startapp polls

path()函数接收 4 个参数,route、view、kwargs、name

django-demo's People

Contributors

tigerwfh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.