Remove FilterMixinRenames metaclass on FilterMixin views?

12 views
Skip to first unread message

powderflask

unread,
Jul 26, 2019, 12:09:37 PM7/26/19
to django-filter
The use of a metaclass on the view prevents mixing in the FilterMixin with Views that use a metaclass for other purposes (metaclass of sub-class must itself be a sub-class of the metaclass of its super).
Comment in code indicates this is a deprecation mechanism slated for removal:
# TODO: remove metaclass in 2.1
class FilterMixin(metaclass=FilterMixinRenames):

 Would you accept a pull request to remove this metaclass?

thanks.

powderflask

unread,
Jul 26, 2019, 12:32:20 PM7/26/19
to django-filter
I found a solution in django-filter Github issues:

class MyMeta(ABCMeta, type(FilterView)):
    pass

class MyView(SuperClassWithABCMeta, FilterView, metaclass=MyMeta):
    pass

Thanks to @rpkilby for this - clean solution, didn't come to mind, much appreciated.
Hope this helps others who stumble on same issue.
Reply all
Reply to author
Forward
0 new messages