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

Impossible to overwrite column attributes in child class #399

Closed
dyve opened this issue Dec 19, 2016 · 3 comments
Closed

Impossible to overwrite column attributes in child class #399

dyve opened this issue Dec 19, 2016 · 3 comments

Comments

@dyve
Copy link
Contributor

dyve commented Dec 19, 2016

Maybe we are missing something, but why does this happen?

class FooBaseTable(tables2.Table):
    key = tables2.Column(verbose_name=_('code'))
    name = tables2.Column(verbose_name=_('name'))


class FooTable1(FooBaseTable):
    pass


class FooTable2(FooBaseTable):
    key = None

Expected result:

  • rendering a FooTable1 does show a column key.
  • rendering a FooTable2 does not show a column key.

Result:

  • both FooTable2 and FooTable2 show a column key.

Are we doing something wrong? Is this a bug or just very unpythonic? Feedback welcome.

dyve added a commit to dyve/django-tables2 that referenced this issue Dec 21, 2016
@dyve
Copy link
Contributor Author

dyve commented Dec 21, 2016

Problem is really bugging us, so here is our suggestion for a fix.

@dyve
Copy link
Contributor Author

dyve commented Dec 21, 2016

@jieter this is blocking work on django-filter integration for us so if you can look at this with some prio we'd be much obliged.

@jieter
Copy link
Owner

jieter commented Dec 21, 2016

I will have a look at it today

@jieter jieter closed this as completed in d8df96d Dec 21, 2016
dyve added a commit to dyve/django-tables2 that referenced this issue Dec 21, 2016
jieter pushed a commit that referenced this issue Dec 21, 2016
* Non-column attributes on child class overwrite column attributes of parent class (fix #399)

* Fix and add to FAQ for #399.
intiocean pushed a commit to intiocean/django-tables2 that referenced this issue Feb 27, 2017
intiocean pushed a commit to intiocean/django-tables2 that referenced this issue Feb 27, 2017
* Non-column attributes on child class overwrite column attributes of parent class (fix jieter#399)

* Fix and add to FAQ for jieter#399.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants