Issue 77: Hacking django's Group no more possible ?
Status:  Duplicate
Owner: ----
Closed:  Oct 2010
Reported by remy.san...@gmail.com, Oct 19, 2010
Hi,

I'm trying to code something that get much inspiration from http://bitbucket.org/macxxx/django_hgroups/src/tip/src/django_hgroups/models.py to add hierarchy to Django's Group.

However, it highly depends on the concept of "register", which is no longer available. Since I don't want to get stuck with version 0.3 for the remaining days of the project, I wonder if there is a workaround to this problem or if the register() function can come back to the project.

Btw, if I try to

Group.__bases__ = (MPTTModel,)
setattr(Group, '__metaclass__', MPTTModelBase)

It looks like not to be working, since that when I call get_ancestors(), I get a "AttributeError: 'Group' object has no attribute '_tree_manager'"

Thanks,
Rémy
Oct 20, 2010
Project Member #1 craig.ds@gmail.com
Interesting use case.

The registration is now done earlier, during class creation. That's why inserting the bases after class creation doesn't work.

I've added a possible workaround in this branch http://github.com/django-mptt/django-mptt/tree/gc77-registration-postcreation

To use it, just do

    from mptt.models import MPTTModelBase
    MPTTModelBase.register(Group, order_insertion_by='foo', ...)

Can you try that and see if it solves your problem? I haven't tested it much at all, I'm guessing there'll be some weird issues with it...
Oct 26, 2010
Project Member #2 craig.ds@gmail.com
Closing in favour of [http://github.com/django-mptt/django-mptt/issues/#issue/19 GH-19]

Rémy, I'd still like your feedback, please try the branch and comment on GH-19 with your thoughts, thanks.


One of these days Github will sort out the issues with their API and I'll migrate all these GC tickets to Github...
Status: Duplicate