Django:我在哪里可以找到呈现管理页面字段的模板?

时间:2023-02-11 15:04:41

I want to change the shape of some fields showed in the admin site.

我想改变管理站点中显示的某些字段的形状。

I found that the template that manage everything is change_form.html with fieldset.html but I cannot find where the fields are actually transformed in html.

我发现管理所有内容的模板是带有fieldset.html的change_form.html,但我找不到字段在html中实际转换的位置。

Basically I want to change the field of the foreign key adding a link to another page.

基本上我想更改外键的字段,添加到另一个页面的链接。

Do you have any idea?

你有什么主意吗?

Thanks, Giovanni

谢谢Giovanni

2 个解决方案

#1


1  

The HTML for a given field is handled by its widget in the render function. If you want to customize the look of a field you could create a custom widget which has the additional HTML you need in the render.

给定字段的HTML由其在渲染功能中的小部件处理。如果要自定义字段的外观,可以创建自定义窗口小部件,该窗口小部件具有渲染中所需的其他HTML。

You can check out the render some of the built in widgets in django/forms/widgets.py (links to the Django trunk).

您可以在django / forms / widgets.py中查看渲染一些内置小部件(链接到Django主干)。

#2


0  

In fieldset.html, the code {{ field.field }} renders the field's HTML representation. to achieve what you want, you'll probably need to define your own widget. you can take a look at admin's widgets.py

在fieldset.html中,代码{{field.field}}呈现字段的HTML表示形式。为了实现你想要的,你可能需要定义自己的小部件。你可以看看admin的widgets.py

#1


1  

The HTML for a given field is handled by its widget in the render function. If you want to customize the look of a field you could create a custom widget which has the additional HTML you need in the render.

给定字段的HTML由其在渲染功能中的小部件处理。如果要自定义字段的外观,可以创建自定义窗口小部件,该窗口小部件具有渲染中所需的其他HTML。

You can check out the render some of the built in widgets in django/forms/widgets.py (links to the Django trunk).

您可以在django / forms / widgets.py中查看渲染一些内置小部件(链接到Django主干)。

#2


0  

In fieldset.html, the code {{ field.field }} renders the field's HTML representation. to achieve what you want, you'll probably need to define your own widget. you can take a look at admin's widgets.py

在fieldset.html中,代码{{field.field}}呈现字段的HTML表示形式。为了实现你想要的,你可能需要定义自己的小部件。你可以看看admin的widgets.py