Django 官方教程翻译项目书栈(BookStack.CN) 构建 创建你的第一个 Django 项目, 第一部分 创建你的第一个 Django 项目, 第一部分 创建项目 用于开发的服务器 创建 Polls 投票应用 编写你的第一个视图 url 参数:regex url 参数:view url 参数:kwargs url 参数:name 来跟着实际项目学习 Django 吧。 在本教程中,我们将创建一个基础的投票网站。 的内置模块冲突) 这样的名字。 我的代码该放在哪? 如果你曾经是老式 PHP 程序员(没有使用过现代框架),你可能会习惯地把代码放在 Web 服务器的文档根目录(比如 /var/www)。但使用 Django 时你不用这样做。而且把所有 Python 代码放在 Web 服务器的根目录不是个好主意,因为这样会 有风险。比如人们可能会在网站上看到你的代码。这不利于网站的安全。 你可以把代码放在文档根目录 以外 Django 项目的 URL 声明,就像是你网站的“目录”。阅读 URL dispatcher 文档来获取更多关于 URL 的内容。 mysite/wsgi.py:当你部署项目到一个兼容 WSGI 的服务器上时所需要的入口点。How to deploy with WSGI 文档内有更多关于这个文件的细节。 让我们验证下项目是否可用。 切换到最外层的 mysite 目录下,如果你已经在这个目录下了,那就运行下面的命令:0 码力 | 103 页 | 1.86 MB | 1 年前3
Django、Vue 和Element UI 前后端原理论述后端 Rest Framework:使用 Django Rest Framework 来构建 RESTful API,方便前端 和其他应用调用后端接口。 数据库配置:配置 Django 项目的数据库连接,通常使用 MySQL 作为后端数据库, 可以在 settings.py 中进行配置。 2.2 前端搭建流程 创建工程(模板)->前端依赖(npm install )->前端服务配置启动 简要说明: 测试天地》七十四 www.51testing.com 依赖包,这些依赖包通常存储在 package.json 文件中。 前端服务配置启动:在项目目录下执行 npm run serve 命令,启动前端开发服务器, 可以在浏览器中预览项目。 三、关键技术介绍 1、后端为什么要创建虚拟环境,创建虚拟环境可以达到什么效果? 隔离项目依赖:通过创建后端虚拟环境,每个项目都拥有独立的 Python 解释器和包 等工具来管理项目的依赖,这样 可以确保项目在不同环境中安装相同的依赖版本,从而避免由于依赖版本不一致而引发 的错误。 提高项目可移植性:将项目的依赖放在虚拟环境中,可以使得项目在不同的计算机 或服务器上都能轻松地部署和运行,而不需要担心依赖问题。 简化依赖管理:虚拟环境可以将项目所需的依赖以及其版本信息保存在一个文件中 (例如 Pipfile.lock),这样可以方便地重现项目的开发环境,使得依赖的安装和管理更加0 码力 | 61 页 | 6.84 MB | 1 年前3
Django 2.2.x DocumentationDjango app, part 1 Creating a project The development server Creating the Polls app Write your first view Writing your first Django app, part 2 Database setup Creating models Activating models Playing with app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app, part 6 instrumentation Examples of model relationship API usage Handling HTTP requests URL dispatcher Writing views View decorators File Uploads Django shortcut functions Generic views Middleware How to use sessions Working0 码力 | 2915 页 | 2.83 MB | 1 年前3
Django 2.1.x DocumentationDjango app, part 1 Creating a project The development server Creating the Polls app Write your first view Writing your first Django app, part 2 Database setup Creating models Activating models Playing with app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app, part 6 instrumentation Examples of model relationship API usage Handling HTTP requests URL dispatcher Writing views View decorators File Uploads Django shortcut functions Generic views Middleware How to use sessions Working0 码力 | 2790 页 | 2.71 MB | 1 年前3
Django 2.1.x Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.5 The view layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 3.12 Conditional View Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 3.13 databases | Providing initial data | Optimize database access | PostgreSQL specific features 1.5 The view layer Django has the concept of “views” to encapsulate the logic responsible for processing a user’s0 码力 | 1910 页 | 6.49 MB | 1 年前3
Django 1.8.x DocumentationCustomize the admin index page Writing your first Django app, part 3 Philosophy Write your first view Writing more views Write views that actually do something Raising a 404 error Use the template system app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app, part 6 optimization Examples of model relationship API usage Handling HTTP requests URL dispatcher Writing views View decorators File Uploads Django shortcut functions Generic views Middleware How to use sessions Working0 码力 | 2454 页 | 2.85 MB | 1 年前3
Django 1.11.x DocumentationDjango app, part 1 Creating a project The development server Creating the Polls app Write your first view Writing your first Django app, part 2 Database setup Creating models Activating models Playing with app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app, part 6 optimization Examples of model relationship API usage Handling HTTP requests URL dispatcher Writing views View decorators File Uploads Django shortcut functions Generic views Middleware How to use sessions Working0 码力 | 2747 页 | 2.67 MB | 1 年前3
Django 2.0.x DocumentationDjango app, part 1 Creating a project The development server Creating the Polls app Write your first view Writing your first Django app, part 2 Database setup Creating models Activating models Playing with app, part 5 Introducing automated testing Basic testing strategies Writing our first test Test a view When testing, more is better Further testing What’s next? Writing your first Django app, part 6 instrumentation Examples of model relationship API usage Handling HTTP requests URL dispatcher Writing views View decorators File Uploads Django shortcut functions Generic views Middleware How to use sessions Working0 码力 | 2746 页 | 2.67 MB | 1 年前3
Django 1.8.x Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.4 The view layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 3.12 Conditional View Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 3.13 databases | Providing initial data | Optimize database access | PostgreSQL specific features 1.4 The view layer Django has the concept of “views” to encapsulate the logic responsible for processing a user’s0 码力 | 1685 页 | 6.01 MB | 1 年前3
Django 1.11.x Documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.5 The view layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 3.12 Conditional View Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 3.13 databases | Providing initial data | Optimize database access | PostgreSQL specific features 1.5 The view layer Django has the concept of “views” to encapsulate the logic responsible for processing a user’s0 码力 | 1878 页 | 6.40 MB | 1 年前3
共 83 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9













