英文:
How to add information to a checkbox in django-admin
问题
在我的Django管理界面(change_form)中,我有几个复选框(不仅仅是删除),其中一些位于TabularInline中。我想让用户知道当他们选择一个复选框时会发生什么。请参见下面的图片。
我已经搜索了很多,但找不到任何信息?我不知道该在哪里搜索!!表单!
英文:
In my Django admin (change_form) I have several checkboxes.(not only delete) some of them in TabularInline.
I want to let the users know what is going to be happened when they select a checkbox. See picture below.
I have searched alot but couldn’t find anything? I don't know where to search!! Form!
答案1
得分: 0
需要覆盖tabular.html
模板
这部分负责复选框的显示
原始内容
{% if inline_admin_formset.formset.can_delete %}
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
{% endif %}
修改后
{% if inline_admin_formset.formset.can_delete %}
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}test{% endif %}</td>
{% endif %}
结果
在创建修改后的tabular.html
版本之后,将其设置为要更改的Inline类的模板。
class YourInline(admin.TabularInline):
template = 'your_path_to_modified_tabular_html/tabular.html'
英文:
You need to override tabular.html
template
this part respond for chek box display
Original
{% if inline_admin_formset.formset.can_delete %}
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
{% endif %}
Modified
{% if inline_admin_formset.formset.can_delete %}
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}test{% endif %}</td>
{% endif %}
Result
After you create modified version of tabular.html
set it as template in Inline class you want to change.
class YourInline(admin.TabularInline):
template = 'your_path_to_modified_tabular_html/tabular.html'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论