关于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:
- 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; }
- 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
相关产品推荐
相关产品推荐

