google-code-export / django-mptt

Automatically exported from code.google.com/p/django-mptt
Other
0 stars 0 forks source link

django-reversion and mptt don't play along if you recover #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
if you recover a model that has mptt with django-reversion you get an error
in signals.py line 110:

old_parent = getattr(instance._default_manager.get(pk=instance.pk),
                             opts.parent_attr)

the problem lies that you try to load the old version that doesn't exist in
the database but the model already has a PK.

maybe make try ... except here

Original issue reported on code.google.com by lauber.p...@gmail.com on 3 Feb 2009 at 7:34

GoogleCodeExporter commented 9 years ago
I'm seeing the same error, without use of django-reversion.  The steps to 
recreate
are to mptt.register any model, and then attempt to .save() a new instance 
where you
specify the id value (or the pk, whatever it's named).  In signals.py it 
assumes this
means the instance exists, and attempts a .get() which fails, as this is a 
pre-save
signal.  A try/except may not work (on line 110), as we probably still want it 
to
behave as if it is a new instance and pass the test on line 92 (or amend the 
test
somehow).

My dirty solution would be a kwarg passed in the .save(), since forced PK's are
somewhat rare.

Original comment by eyep...@gmail.com on 10 Mar 2009 at 5:22

GoogleCodeExporter commented 9 years ago
Duplicate of issue 17

Original comment by jonathan.buchanan on 1 Jul 2009 at 2:44