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 年前3
Django、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 年前3
Django 2.1.x DocumentationTutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. • Topic guides Django works, but this isn’t intended to be a tutorial or reference – but we’ve got both! When you’re ready to start a project, you can start with the tutorial or dive right into more detailed documentation latest stable release. Always refer to the documentation that corresponds to the version of Django you’re using! If you do either of the first two steps, keep an eye out for parts of the documentation marked0 码力 | 1910 页 | 6.49 MB | 1 年前3
Django 2.0.x DocumentationTutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. • Topic guides Django works, but this isn’t intended to be a tutorial or reference – but we’ve got both! When you’re ready to start a project, you can start with the tutorial or dive right into more detailed documentation latest stable release. Always refer to the documentation that corresponds to the version of Django you’re using! If you do either of the first two steps, keep an eye out for parts of the documentation marked0 码力 | 1880 页 | 6.41 MB | 1 年前3
Django 3.0.x Documentationwho created them? My admin-site CSS and images showed up fine using the development server, but they’re not displaying when using mod_wsgi. My “list_filter” contains a ManyToManyField, but the filter doesn’t reverse() reverse_lazy() resolve() get_script_prefix() django.urls functions for use in URLconfs path() re_path() include() register_converter() django.conf.urls functions for use in URLconfs static() url() Tutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps”. Topic guides discuss0 码力 | 3085 页 | 2.95 MB | 1 年前3
Django 2.2.x Documentationwho created them? My admin-site CSS and images showed up fine using the development server, but they’re not displaying when using mod_wsgi. My “list_filter” contains a ManyToManyField, but the filter doesn’t reverse() reverse_lazy() resolve() get_script_prefix() django.urls functions for use in URLconfs path() re_path() include() register_converter() django.conf.urls functions for use in URLconfs static() url() Tutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. Topic guides discuss0 码力 | 2915 页 | 2.83 MB | 1 年前3
Django 1.8.x DocumentationDjango works, but this isn’t intended to be a tutorial or reference – but we’ve got both! When you’re ready to start a project, you can start with the tutorial or dive right into more detailed documentation latest stable release. Always refer to the documentation that corresponds to the version of Django you’re using! If you do either of the first two steps, keep an eye out for parts of the documentation marked advice on how to remove older versions of Django and install a newer one. Where to get help: If you’re having trouble going through this tutorial, please post a message to django-users or drop by #django0 码力 | 1685 页 | 6.01 MB | 1 年前3
Django 1.11.x DocumentationTutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. • Topic guides Django works, but this isn’t intended to be a tutorial or reference – but we’ve got both! When you’re ready to start a project, you can start with the tutorial or dive right into more detailed documentation latest stable release. Always refer to the documentation that corresponds to the version of Django you’re using! If you do either of the first two steps, keep an eye out for parts of the documentation marked0 码力 | 1878 页 | 6.40 MB | 1 年前3
Django 2.1.x Documentationwho created them? My admin-site CSS and images showed up fine using the development server, but they’re not displaying when using mod_wsgi. My “list_filter” contains a ManyToManyField, but the filter doesn’t reverse() reverse_lazy() resolve() get_script_prefix() django.urls functions for use in URLconfs path() re_path() include() register_converter() django.conf.urls functions for use in URLconfs static() url() Tutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. Topic guides discuss0 码力 | 2790 页 | 2.71 MB | 1 年前3
Django 2.0.x Documentationwho created them? My admin-site CSS and images showed up fine using the development server, but they’re not displaying when using mod_wsgi. My “list_filter” contains a ManyToManyField, but the filter doesn’t reverse() reverse_lazy() resolve() get_script_prefix() django.urls functions for use in URLconfs path() re_path() include() register_converter() django.conf.urls functions for use in URLconfs static() url() Tutorials take you by the hand through a series of steps to create a Web application. Start here if you’re new to Django or Web application development. Also look at the “First steps” below. Topic guides discuss0 码力 | 2746 页 | 2.67 MB | 1 年前3
共 91 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10













