unfoldadmin / django-unfold

Modern Django admin theme for seamless interface development
https://unfoldadmin.com
MIT License
1.03k stars 96 forks source link

Enabling Customization of Widgets #340

Closed HT-Moh closed 1 week ago

HT-Moh commented 1 month ago

It would be beneficial to have a method to modify variables such as SELECT_CLASSES, BASE_INPUT_CLASSES, and BASE_CLASSES inside widgets.py. For instance, to alter the widget's style (refer to the screenshot) seems not to be possible or at least not straightforward without overriding bunch of classes. the style is dynamically added in ModelAdminMixin function formfield_for_foreignkey and formfield_for_choice_field. I think the solution is to move all style classed to settings.py and change the imports on admin.py

kwargs["widget"] = forms.Select(attrs={"class": " ".join(SELECT_CLASSES)})

the change on the style done in firebug by removing w-full and max-w-2x and adding flex-grow

2024-04-03_16-05

lukasvinclav commented 1 week ago

From the screenshot it is hard to find out where exactly this problem is occurring. I already merged a PR fixing similar issue. If the problem persist, create a new issue with more information how to replicate the problem.

Regarding the CSS classes in settings.py, I provided an explanation in your PR.