Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bulk deletion of items does not update lft and rght fields #155

Closed
jetli opened this Issue · 7 comments

4 participants

@jetli

I find some problem when delete items in django admin UI, steps to repro:

  1. in item list, select one or more items
  2. choose action "Delete selected xxx" from Action dropdown, and click Go button
  3. click "Yes I'm sure" button to delete items in "Are you sure?" confirmation page.
  4. go to database to see that lft and rght values are not updated at al for remaining items.

but if I go into one item, and try to delete the item from there, then there is no problem.
my code :

class Area(MPTTModel):
    name = models.CharField(max_length = 200)
    slug = models.SlugField(max_length = 200)
    parent = TreeForeignKey('self', null = True, blank = True, related_name = 'children')

    def __unicode__(self):
        return self.name

    class MPTTMeta:
        order_insertion_by = ['name']

django : 1.3.1
mppt : 0.5
backend : mysql
os : mac os x

@craigds
Collaborator

Right, mptt doesn't currently do anything with queryset updates/deletes because arbitrary lots-of-rows mptt updates are difficult to solve efficiently. This is something I'd like to fix but haven't had the time to work on a patch.

The implementation of a fix is probably not simple. As a workaround, you could override the delete_selected action in the admin to do a full tree rebuild. That's not nice either but it'll keep the database consistent.

@jetli jetli closed this
@jetli

Thanks, Craig

@floledermann

So why is this issue closed, then? As far as I undestand this is still an open issue in the current version...

@floledermann

Btw. see http://stackoverflow.com/q/5591893/171579 for an example of how to disable / override the delete_selected action as a workaround.

@craigds craigds reopened this
@craigds
Collaborator

Yes, it is still an issue, so fair enough

@matthiask matthiask changed the title from lft and rght not updated when delete items in django admin UI to Bulk deletion of items does not update lft and rght fields
@matthiask
Collaborator

For later reference.

Related issuse:
feincms/feincms#514

Adding disable_mptt_updates around the deletion:
feincms/feincms@c9b93c3

Replacing the default delete_selected action:
https://github.com/feincms/feincms/blob/c9b93c3637acaf396c78142d4e7c2b914e30a286/feincms/admin/tree_editor.py#L554

@matthiask matthiask added Defect Documentation and removed Defect labels
@matthiask matthiask referenced this issue from a commit in matthiask/django-mptt
@matthiask matthiask Update MPTT properties also when bulk deleting issues through the adm…
…in interface

Refs #155.
3f9aff6
@matthiask matthiask closed this in 2ede6cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.