- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Django 的新手,但我真的很喜欢它。但有时我似乎会遇到一些我似乎没有把事情弄对的地方。所以,我请求一些帮助和指导。
我正在尝试为我的一个模型扩展对象工具,这样我就可以在历史记录旁边添加一个打印按钮。
我的模板如下:
project/app/templates/admin/
我成功扩展了 base_site.html,没有任何问题。
project/app/templates/admin/base_site.html
但是,当我像这样添加 change_form.html 时:
project/app/templates/admin/change_form.html
具有以下内容:
{% extends 'admin/change_form.html' %}
{% block object-tools %}
<a href="one">One</a>
<a href="one">Two</a>
{% endblock %}
我遇到异常:调用 Python 对象时超出最大递归深度
这似乎是我遗漏了一些非常基本的东西。
我尝试过的事情:
我很困惑,没有成功。
P.S.:我也在使用这里的 Bootstrap 主题 http://riccardo.forina.me/bootstrap-your-django-admin-in-3-minutes/但出于这个问题的目的,我目前没有使用它。
最佳答案
问题是 {% extend %}
block 中的 admin/change_form.html
被解析为 project/app/templates/admin/change_form .html
.
一个解决方案是创建一个以您的应用命名的 templates
子目录 - 可能是 project/templates/admin/app/change_form.html
。
In order to override one or more of them, first create an admin directory in your project’s templates directory. This can be any of the directories you specified in TEMPLATE_DIRS.
Within this admin directory, create sub-directories named after your app.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template
关于python - Django 1.5 扩展 admin/change_form.html 对象工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18196506/
如何在 django admin change_form.html 中显示登录用户的用户组?我想在模型的change_form中显示登录用户的组名。例如,我可以使用 {{ user }} 标签显示用户
我在 template/admin/change_form.html 中有以下模板: {% extends "admin/change_form.html" %} {% block extrahead
我有两个表,任务和项目。每个任务都有一个项目(每个项目可以有 N 个任务)。 添加或编辑任务时,项目显示为应有的下拉列表,但下拉列表按 ID 排序(或根本不排序)。因为我开始有很多项目,有没有办法按字
我有一种情况,我覆盖了给定模型的 admin_change.html 模板。我创建了一个文件,例如: /myproject/templates/admin/myapp/mymodel/change_f
我正在使用 Django 1.2.4。我有一个具有 JavaScript 媒体的模型的管理类。我想让数据库中的一些数据可供这些脚本使用。我不确定执行此操作的最佳方法是什么。 也许是这样的:(并不是说我
我有点迷失,不知道如何继续,经过大量搜索后我认为我做得不对。 我的问题是我有一个像这样的优惠类模型: class Offer(models.Model): design_hours = mod
假设我有两个模型: class Book(models.Model): name = models.CharField(max_length=50) library = models.
我想在管理界面的添加/更改表单中添加自定义按钮。默认只有三个: 保存并添加另一个 保存并继续编辑 保存 我在 forms.py 文件中创建了一些自定义方法,我想创建按钮来调用这些方法。我使用了片段 h
是否可以通过管理模板中的 jQuery/javascript 将数据添加到 querydict/post 变量?我想在点击管理员内置的保存按钮时提交一些额外的数据。 问候 最佳答案 没有。这意味着您有
我是 Django 的新手,但我真的很喜欢它。但有时我似乎会遇到一些我似乎没有把事情弄对的地方。所以,我请求一些帮助和指导。 我正在尝试为我的一个模型扩展对象工具,这样我就可以在历史记录旁边添加一个打
我想在 change_form 页面的管理员中创建一个可单击的只读 URL 字段。我尝试了一个小部件,但很快意识到小部件仅适用于表单字段。所以,在我尝试用 jQuery 解决这个问题(查找和替换或其他
我是一名优秀的程序员,十分优秀!