Django 官方教程翻译项目
之类的冗余的后缀放到 URL 里。 为了设计你自己的 URL,你需要创建一个叫做 URLconf 的 Python 模块。一张包含 URL 匹配模 式和 Python 回调函数之间的映射表。URLconf 也有利于将 Python 代码与 URL 解耦合(译 注:使各个模块分离,独立)。 下面这个 URLconf 适用于前面 Reporter/Article 的例子: 1. # mysite/news/urls 注意 你得避免使用 Python 或 Django 的内部保留字来命名你的项目。具体地说,你得避免使用像 django(会和 Django 自己冲 突) 或 test(会和 Python 的内置模块冲突) 这样的名字。 我的代码该放在哪? 如果你曾经是老式 PHP 程序员(没有使用过现代框架),你可能会习惯地把代码放在 Web 服务器的文档根目录(比如 /var/www)。但使用 Django 以被很多个项目使用。 你的应用可以放在 Python path 中的任何目录里。在本教程中,我们将直接在 manage.py 所在 的目录里创建投票应用,这样它就能作为顶级模块被引入,而不是作为 mysite 的子模块。 请确定你现在处于 manage.py 所在的目录下,然后运行这行命令来创建一个应用: 1. $ python manage.py startapp polls 这将会创建一个0 码力 | 103 页 | 1.86 MB | 1 年前3Django、Vue 和Element UI 前后端原理论述
后端服务配置启动:在虚拟环境下,通过 Django 的 manage.py 启动服务,例如:python manage.py runserver。 后端创建子应用:根据项目的需要,可以创建多个子应用(app)来管理不同的功能 模块。 后端 Rest Framework:使用 Django Rest Framework 来构建 RESTful API,方便前端 和其他应用调用后端接口。 数据库配置:配置 Django 项目的数据库连接,通常使用 依赖、 构建工具和其他相关资源。以下是 npm 在前端开发中的应用介绍: 依赖管理:npm 可以管理前端项目的依赖,开发者可以在项目的 package.json 文件中 声明项目所依赖的第三方模块和库,以及其版本信息。在安装项目时,运行 npm install 命令会自动从 npm 仓库下载并安装这些依赖,使得项目能够在开发和生产环境中正常运 行。 脚本执行:在 package.json 些构建工具可以帮助开发者将前端代码进行打包、压缩、优化和处理,以提高前端项目 的性能和可维护性。 版本控制:npm 支持语义化版本控制(Semantic Versioning),开发者可以在 package.json 文件中声明模块的版本范围,以确保在安装依赖时不会引入不兼容的版本。 四、开发环境 Pycharm 使用非社区版本,我用的最新版本 (release 版) 在安装过程中,有的安装包在太老的版本中安装不成功。0 码力 | 61 页 | 6.84 MB | 1 年前3Django 2.2.x Documentation
(CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Session security User-uploaded content Additional security topics Performance and optimization Introduction system. django.contrib.contenttypes – A framework for content types. django.contrib.sessions – A session framework. django.contrib.messages – A messaging framework. django.contrib.staticfiles – A framework time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and0 码力 | 2915 页 | 2.83 MB | 1 年前3Django 2.1.x Documentation
(CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Session security User-uploaded content Additional security topics Performance and optimization Introduction system. django.contrib.contenttypes – A framework for content types. django.contrib.sessions – A session framework. django.contrib.messages – A messaging framework. django.contrib.staticfiles – A framework time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and0 码力 | 2790 页 | 2.71 MB | 1 年前3Django 2.1.x Documentation
• django.contrib.contenttypes – A framework for content types. • django.contrib.sessions – A session framework. • django.contrib.messages – A messaging framework. • django.contrib.staticfiles – A time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: Listing 42: polls/tests.py from django.urls import how you can split these models across databases: • each one of contenttypes.ContentType, sessions.Session and sites.Site can be stored in any database, given a suitable router. • auth models — User, Group0 码力 | 1910 页 | 6.49 MB | 1 年前3Django 1.11.x Documentation
(CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Session security User-uploaded content Additional security topics Performance and optimization Introduction system. django.contrib.contenttypes – A framework for content types. django.contrib.sessions – A session framework. django.contrib.messages – A messaging framework. django.contrib.staticfiles – A framework time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and0 码力 | 2747 页 | 2.67 MB | 1 年前3Django 2.0.x Documentation
(CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Session security User-uploaded content Additional security topics Performance and optimization Introduction system. django.contrib.contenttypes – A framework for content types. django.contrib.sessions – A session framework. django.contrib.messages – A messaging framework. django.contrib.staticfiles – A framework time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and0 码力 | 2746 页 | 2.67 MB | 1 年前3Django 1.11.x Documentation
• django.contrib.contenttypes – A framework for content types. • django.contrib.sessions – A session framework. • django.contrib.messages – A messaging framework. • django.contrib.staticfiles – A time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse 48 how you can split these models across databases: • each one of contenttypes.ContentType, sessions.Session and sites.Site can be stored in any database, given a suitable router. • auth models — User, Group0 码力 | 1878 页 | 6.40 MB | 1 年前3Django 2.0.x Documentation
• django.contrib.contenttypes – A framework for content types. • django.contrib.sessions – A session framework. • django.contrib.messages – A messaging framework. • django.contrib.staticfiles – A time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and how you can split these models across databases: • each one of contenttypes.ContentType, sessions.Session and sites.Site can be stored in any database, given a suitable router. • auth models — User, Group0 码力 | 1880 页 | 6.41 MB | 1 年前3Django 1.10.x Documentation
(CSRF) protection SQL injection protection Clickjacking protection SSL/HTTPS Host header validation Session security User-uploaded content Additional security topics Performance and optimization Introduction system. django.contrib.contenttypes – A framework for content types. django.contrib.sessions – A session framework. django.contrib.messages – A messaging framework. django.contrib.staticfiles – A framework time you make any change that might affect this - so let’s also create a test, based on our shell session above. Add the following to polls/tests.py: polls/tests.py from django.urls import reverse and0 码力 | 2538 页 | 2.59 MB | 1 年前3
共 50 条
- 1
- 2
- 3
- 4
- 5