You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于django-baton导致Django Admin水平radio fields垂直显示的修复问询

Django Admin Horizontal Radio Fields Turn Vertical After Installing django-baton: Will This Be Fixed?

Hey there! Great question—this is a super common hiccup when using third-party Admin themes like django-baton, since their custom styles often override Django's default admin styling. Let's break down what's going on and whether a fix is on the horizon:

Will this issue get an official fix?

  • It depends entirely on whether the django-baton maintainers are aware of the problem and prioritize it. First, check if this bug has already been reported in the project's issue tracker. If it's a known issue, there’s a solid chance it’ll be addressed in a future update.
  • If no one’s flagged it yet, submitting a detailed bug report (with steps to reproduce, your Django/django-baton versions, and even screenshots) will help the team understand and fix it faster. Maintainers rely on user feedback to catch these kinds of styling conflicts!

Temporary workaround to restore horizontal radio fields

In the meantime, you can override the theme’s styles with custom CSS to get your horizontal radio buttons back right away:

  1. Create a custom CSS file (e.g., static/css/custom_admin.css) with this rule:
/* Override django-baton's vertical radio layout */
.form-row .baton-radio-list {
    display: flex;
    flex-direction: row;
    gap: 1.5rem;
    align-items: center;
}
  1. Link this CSS file in your ModelAdmin class:
from django.contrib import admin
from .models import YourModel

class YourModelAdmin(admin.ModelAdmin):
    radio_fields = {"your_field_name": admin.HORIZONTAL}

    class Media:
        css = {
            "all": ("css/custom_admin.css",)
        }

admin.site.register(YourModel, YourModelAdmin)

This will force the radio fields back into the horizontal arrangement you configured in your Admin setup, bypassing django-baton's default vertical styling.

内容的提问来源于stack exchange,提问作者A.R. Bayri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:24:42