My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 20: mptt after qs-refactor merged into trunk (SOLVED)
3 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Sep 2010


 
Reported by kryla...@gmail.com, Apr 29, 2008
Mppt works now incorrect with child of models that was registered.
As far i know mptt does not receive pre_* signals. 
So i have modified mptt for dynamic determination of _meta. (When child
model saves, mptt must use _meta of her parent if parent was already
registered).
My modifications:
 __init__.py
        - parent_model attr added to register()
        - logic of register() a bit changed
        - if model has already registered parent, i add "mptt_parent_meta"
          attribute
 utils.py
        - new method get_actual_opts()
 managers.py
        - lines "opts = self.model._meta" changed to   
                "opts = get_actual_opts(self.model)"
 signals.py
        - lines "opts = instance._meta" changed to   
                "opts = get_actual_opts(instance)"

It works for me, but you must manually create fields for parent model.
lft = models.PositiveIntegerField(db_index=True, editable=False)
rght = models.PositiveIntegerField(db_index=True, editable=False)
tree_id = models.PositiveIntegerField(db_index=True, editable=False)
level = models.PositiveIntegerField(db_index=True, editable=False) 

So its child can use it.

Hope its helps to make project better. If you have some questions, please
feel free to contact me by email.
Alex Dobretsov, my email  krylatij@gmail.com
       

                
              

mptt.rar
39.4 KB   Download
Apr 29, 2008
#1 kryla...@gmail.com
Forget to say, if we have 2 models use syntax like 

class A(models.Model):
     lft = models.PositiveIntegerField(db_index=True, editable=False)
     rght = models.PositiveIntegerField(db_index=True, editable=False)
     tree_id = models.PositiveIntegerField(db_index=True, editable=False)
     level = models.PositiveIntegerField(db_index=True, editable=False) 
     ....

class B(A):
     ....
mptt.register(A)
mptt.register(B, parent_model=A)

May 5, 2008
#2 flavio.c...@gmail.com
attached Alex Dobretsov's patch as a .diff for convenience.
qs-rf.diff
7.1 KB   View   Download
Jan 27, 2009
#3 djbamb...@gmail.com
Is there a version of this in existence that will work with Django 1.0.1+?
Many thanks!
Sep 3, 2010
#4 matjaz.c...@gmail.com
Fixed in the latest stable release.
Status: Fixed

Powered by Google Project Hosting