在Django admin中,如何在使用filter_horizo​​ntal时增加ManyToMany字段小部件的宽度?

时间:2022-03-07 07:21:43

In Django admin, how can I increase the width of the ManyToMany field's widget when using filter_horizontal?

在Django admin中,如何在使用filter_horizo​​ntal时增加ManyToMany字段小部件的宽度?

1 个解决方案

#1


4  

You could apply custom classes to the fields using ModelAdmin Fieldsets you wanted to change and add an extra stylesheet with:

您可以使用要更改的ModelAdmin Fieldsets将自定义类应用于字段,并添加一个额外的样式表:

class MyAdmin(admin.ModelAdmin):
    class Media:
        css = {
            "all": ("my_styles.css",)
        }

Otherwise you'll have to write your own admin templates or widgets.

否则,您将不得不编写自己的管理模板或小部件。

#1


4  

You could apply custom classes to the fields using ModelAdmin Fieldsets you wanted to change and add an extra stylesheet with:

您可以使用要更改的ModelAdmin Fieldsets将自定义类应用于字段,并添加一个额外的样式表:

class MyAdmin(admin.ModelAdmin):
    class Media:
        css = {
            "all": ("my_styles.css",)
        }

Otherwise you'll have to write your own admin templates or widgets.

否则,您将不得不编写自己的管理模板或小部件。