django-unfold
django-unfold copied to clipboard
feat: Enable overriding widget classes
- Move widget class variables to settings for centralized management.
- Update widgets to retrieve class attributes using the
get_config
function. - Include new variables in the
get_config
function to support customization. - Clean up imports in admin files and use
get_config
for widget classes. - Using
get_config
onforms.py
andsites.py
- Using
get_config
on filters and import_exportforms.py
Usage: settings.py
BASE_CLASSES = [
'border',
'bg-white',
'font-medium',
'rounded-md',
'shadow-sm',
'text-gray-500',
'text-sm',
'focus:ring',
'focus:ring-primary-300',
'focus:border-primary-600',
'focus:outline-none',
'group-[.errors]:border-red-600',
'group-[.errors]:focus:ring-red-200',
'dark:bg-gray-900',
'dark:border-gray-700',
'dark:text-gray-400',
'dark:focus:border-primary-600',
'dark:focus:ring-primary-700',
'dark:focus:ring-opacity-50',
'dark:group-[.errors]:border-red-500',
'dark:group-[.errors]:focus:ring-red-600/40',
]
SELECT_CLASSES = [
*BASE_CLASSES,
'px-3',
'py-2',
'pr-8',
'flex-grow',
'max-w-2xl',
'appearance-none',
'truncate',
]
UNFOLD = {
'SITE_TITLE': "Site name",
'SITE_HEADER': None
'SELECT_CLASSES': SELECT_CLASSES,
}
You can change classed by adding them to UNFOLD #340