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

thead class cannot be overridden in bootstrap 4 #671

Closed
stanorama opened this issue Jun 14, 2019 · 1 comment
Closed

thead class cannot be overridden in bootstrap 4 #671

stanorama opened this issue Jun 14, 2019 · 1 comment

Comments

@stanorama
Copy link
Contributor

django 2.2.2
django-tables2 2.0.6
Firefox 67.0.1 64-bit
Chrome 74.0.3729.169 64-bit

Passing the class attribute of thead does not work when using the bootstrap 4 template.
This is caused by the inclusion of the default class="thead-default" in the template.
Any other attribute aside from class is being passed correctly.

bootstrap.html

<thead {{ table.attrs.thead.as_html }}>

bootstrap4.html

<thead class="thead-default" {{ table.attrs.thead.as_html }}>

Setting attrs in table meta:

class Meta:
attrs = {'class': 'table table-hover', 'thead':{'class': 'thead-light', 'id':'OK!'}}

From Chrome Inspector showing class has stayed unchanged
image

I have seen no formatting difference by removing the hard coded class in the template.
tbody and tfoot do not have a hard coded class.

@stanorama stanorama changed the title thead class cannot overridden in bootstrap 4 thead class cannot be overridden in bootstrap 4 Jun 14, 2019
@jieter
Copy link
Owner

jieter commented Jun 20, 2019

@stanorama thanks for the report.

The table tag shows the proper way to have a default value and overridable class attribute:

<table {% render_attrs table.attrs class="table" %}>

Are you willing to open a PR fixing this issue?

stanorama added a commit to stanorama/django-tables2 that referenced this issue Jun 20, 2019
Remove class="thead-default" from thead.
This was preventing the class from being updated as part of the attrs as demonstrated in 
jieter#671
jieter pushed a commit that referenced this issue Jun 28, 2019
Remove class="thead-default" from thead.
This was preventing the class from being updated as part of the attrs as demonstrated in 
#671
@jieter jieter closed this as completed Jul 6, 2019
AppleJin512 pushed a commit to AppleJin512/django-tables2 that referenced this issue Feb 21, 2023
Remove class="thead-default" from thead.
This was preventing the class from being updated as part of the attrs as demonstrated in 
jieter/django-tables2#671
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

2 participants