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 CMS 2.1.x Documentation
specify from what level to which level should the navigation be rendered. If you have a home as a root node and don’t want to display home you can render the navigation only after level 1. The third parameter specifies how many levels of navigation should be dis- played if a node is not a direct ancestor or descendant of the current active node. Finally, the fourth parameter, extra_active (default=100), specifies specifies how many levels of descendants of the currently active node should be displayed. Some Examples Complete navigation (as a nested list): {% load cache menu_tags %}-
{% show_menu 0 100 100 100 %}
0 码力 | 63 页 | 485.38 KB | 6 月前3Django CMS 2.3.x Documentation
level the navigation shoud be rendered and at which level it should stop. If you have home as a root node and don’t want to display home you can render the navigation only after level 1. The third parameter if a node is not a direct ancestor or descendant of the current active node. The fourth parameter, extra_active (default=100), specifies how many levels of descendants of the currently active node should templates {{ node.is_leaf_node }} Is it the last in the tree? If true it doesn’t have any children. (This normally comes from mptt.) {{ node.level }} The level of the node. Starts at 0. {{ node.menu_level0 码力 | 92 页 | 666.41 KB | 6 月前3Django CMS 2.1.x Documentation
specify from what level to which level should the navigation be rendered. If you have a home as a root node and don’t want to display home you can render the navigation only after level 1. The third parameter specifies how many levels of navigation should be displayed if a node is not a direct ancestor or descendant of the current active node. Finally, the fourth parameter, extra_active (default=100), specifies specifies how many levels of descendants of the currently active node should be displayed. 5.1.1. Some Examples Complete navigation (as a nested list): {% load cache menu_tags %}-
{% show_menu 0 100
0 码力 | 81 页 | 554.09 KB | 6 月前3Django CMS 2.2.x Documentation
specify from what level to which level should the navigation be rendered. If you have a home as a root node and don’t want to display home you can render the navigation only after level 1. The third parameter if a node is not a direct ancestor or descendant of the current active node. The fourth parameter, extra_active (default=100), specifies how many levels of descendants of the currently active node should like login, logout and third-party apps. 1.6.5 Properties of Navigation Nodes in templates {{ node.is_leaf_node }} Is it the last in the tree? If true it doesn’t have any children. (This normally comes from0 码力 | 76 页 | 627.98 KB | 6 月前3django cms 2.2.x Documentation
specify from what level to which level should the navigation be rendered. If you have a home as a root node and don’t want to display home you can render the navigation only after level 1. The third parameter if a node is not a direct ancestor or descendant of the current active node. The fourth parameter, extra_active (default=100), specifies how many levels of descendants of the currently active node should templates {{ node.is_leaf_node }} Is it the last in the tree? If true it doesn’t have any children. (This normally comes from mptt.) {{ node.level }} The level of the node. Starts at 0. {{ node.menu_level0 码力 | 105 页 | 679.29 KB | 1 年前3Django CMS 2.4.x Documentation
site has 3 languages (English, German and French) and the second site has only Dutch. The default node defines default behavior for all languages. You can overwrite the default settings with language specific hide_untranslated as False globally. The English language overwrites this behavior. Every language node needs at least a code and a name property. code is the iso 2 code for the language. And name is the settings file. But maybe you want to leave the language name as it is. What are the properties a language node can have? code String. RFC5646 code of the language. Example: "en". Note: Is required for every language0 码力 | 104 页 | 709.98 KB | 6 月前3Django CMS 2.4.x Documentation
site has 3 languages (English, German and French) and the second site has only Dutch. The default node defines default behavior for all languages. You can overwrite the default settings with language specific hide_untranslated as False globally. The English language overwrites this behavior. Every language node needs at least a code and a name property. code is the iso 2 code for the language. And name is the settings file. But maybe you want to leave the language name as it is. What are the properties a language node can have? 3.4.1.1. code String. RFC5646 code of the language. Example: "en". Note Is required for0 码力 | 156 页 | 727.78 KB | 6 月前3django cms 4.1.x Documentation
Poll.objects.all(): node = NavigationNode( title=poll.question, url=reverse("polls:detail", args=(poll.pk,)), id=poll.pk, # unique id for this node within the menu ) nodes.append(node) return nodes menu_pool be required on the subset of nodes left after cutting. Nodes Nodes are assembled in a tree. Each node is an instance of the menus.base.NavigationNode class. A NavigationNode has attributes such as URL dictionary that’s provided for you to add arbitrary attributes to, rather than placing them directly on the node itself, where they might clash with something. 56 Chapter 5. Software version requirements and release0 码力 | 357 页 | 1.99 MB | 1 年前3
共 55 条
- 1
- 2
- 3
- 4
- 5
- 6