-
Notifications
You must be signed in to change notification settings - Fork 428
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
excluded column not removed from sequence #205
Comments
Upvote! Fell into the exactly same trap with django_tables2 version 1.0.4. |
Finally started looking at this. I reduced the example to this: class PersonTable(tables.Table):
class Meta:
model = Person
fields = ()
sequence = ('first_name', 'last_name', 'occupation')
class AnotherPersonTable(PersonTable):
class Meta(PersonTable.Meta):
exclude = ('first_name', 'last_name') Resulting in the error in
|
@mbertheau Thanks for reporting the issue, sorry it took so long to fix. Next time it will really help to have a simple, compact reproducible test case. |
It seems this is not fixed at all, because instantiating the def test_exclude_should_work_on_sequence_too():
'''
It should be possible to define a sequence on a table
and exclude it in a child of that table.
'''
class PersonTable(tables.Table):
first_name = tables.Column()
last_name = tables.Column()
occupation = tables.Column()
class Meta:
model = Person
sequence = ('first_name', 'last_name', 'occupation')
class AnotherPersonTable(PersonTable):
class Meta(PersonTable.Meta):
exclude = ('first_name', 'last_name')
tableA = PersonTable(Person.objects.all())
assert tableA.columns.names() == ['first_name', 'last_name', 'occupation']
tableB = AnotherPersonTable(Person.objects.all())
assert tableB.columns.names() == ['occupation'] |
With this code:
I get
The reason is that while
ParticipantTable.sequence
is enforced by reorderingbase_columns
, a potential exclusion is not taken into account.A workaround is to specify
sequence
onTrainerParticipantTable
and leave 'register_datetime` out.The text was updated successfully, but these errors were encountered: