Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Adding CSS classes to widgets #81

Open
nategro opened this issue Apr 19, 2018 · 3 comments
Open

[Question] Adding CSS classes to widgets #81

nategro opened this issue Apr 19, 2018 · 3 comments

Comments

@nategro
Copy link

nategro commented Apr 19, 2018

I am looking for an opportunity to add custom css classes to a form widget and extend its 'form-control' class by using the template tag. Unfortunately the parameter 'field_class' modifies a higher-level DIV.

@dyve
Copy link
Member

dyve commented Aug 9, 2019

If there is no interest in discussing this any further, I think we should close this issue.

@1358
Copy link

1358 commented Oct 15, 2020

Just stumbleded around this issue trying to find an "easy" way to add custom css (and data-attributes) to a widget (in order to use bootstrap-select).
Kinda surprised that this is not supported.

@1358
Copy link

1358 commented Oct 15, 2020

However you can use django-widget-tweaks in order to customize the input widget before it is handled by django-bootsrap4. This might be a nice solution:

{% bootstrap_field form.field|add_class:"what_ever_class_you_like"|attr:"data-foo:bar" %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants