django设置model后台编辑框宽度

后台编辑文章title的输入框太窄了。设置长一点

class PostAdmin(admin.ModelAdmin):
    list_display = ('title', 'created_on', "post_status",)
    list_filter = ("post_status",)
    search_fields = ['title', 'content']
    list_per_page = 20

    def get_form(self, request, obj=None, **kwargs):
        form = super(PostAdmin, self).get_form(request, obj, **kwargs)
        form.base_fields['title'].widget.attrs['style'] = 'width: 45em;'
        return form

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注