Closed GoogleCodeExporter closed 9 years ago
By the way, I'm currently able to work around the problem by doing a two-step
save, i.e.:
>>> category.save(raw=True)
>>> category.save()
Original comment by david...@gmail.com
on 21 Mar 2008 at 6:26
I'm trying to do your workaround, but I get this error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/tommycli/Development/pyImpulsestorm/djKeepword/durustodj.py", line 73,
in main
recurseProcessWork(rootwork, notebook)
File "/home/tommycli/Development/pyImpulsestorm/djKeepword/durustodj.py", line 10,
in recurseProcessWork
processWork(work, notebook)
File "/home/tommycli/Development/pyImpulsestorm/djKeepword/durustodj.py", line 24,
in processWork
djWork.save(raw=True)
File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 264, in save
','.join(placeholders)), db_values)
File "/usr/lib/python2.5/site-packages/django/db/backends/util.py", line 18, in execute
return self.cursor.execute(sql, params)
File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line
133, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: notebooks_work.lft may not be NULL
Any ideas?
Original comment by tommy...@ucla.edu
on 23 Mar 2008 at 9:03
Sorry, I forgot a line:
>>> category.lft = category.rght = category.tree_id = category.level = 0
>>> category.save(raw=True)
>>> category.save()
Original comment by david...@gmail.com
on 23 Mar 2008 at 7:10
I tried the workaround but it doesn't work for me. It saves the instance without
errors alright, but the tree does not contain any useful mptt info after the
save, so
things like is_leaf_node() no longer work.
A quick hack in the source 'fixed' the problem (normal save() works with this):
# mptt.signals.py
# line 102: (extra check for existence of instance with given pk)
if not instance.pk or not
instance._default_manager.filter(pk=instance.pk).count():
# mptt.managers.py
# comment out line 120 and 121 (this check breaks when creating with custom pk)
#if node.pk:
# raise ValueError(_('Cannot insert a node which has already been saved.'))
I'm sure there are better solutions, but it works for me and I don't update the
tree
very much after an initial import of legacy data (_with_ pk values that need to
be
maintained)
Maybe this will help the developers in pinpointing and fixing this bug in the
near
future (hint hint), because this is a great application!
Original comment by rvdri...@gmail.com
on 26 Mar 2008 at 8:35
Yes, allow me to also put in a vote in favor of this application being
terrific. Keep
it coming!
Original comment by tommy...@ucla.edu
on 14 Apr 2008 at 3:07
Issue 49 has been merged into this issue.
Original comment by jonathan.buchanan
on 3 Jul 2009 at 10:44
Original comment by craig.ds@gmail.com
on 13 Nov 2010 at 9:35
Fixed in master:
https://github.com/django-mptt/django-mptt/compare/216d62a049b439cc7b01a82cb908f
d838dc9528e...master
Original comment by craig.ds@gmail.com
on 13 Nov 2010 at 10:40
Original issue reported on code.google.com by
david...@gmail.com
on 21 Mar 2008 at 6:16