Login

Tag "mptt"

Snippet List

updated django-mptt enabled FilteredSelectMultiple m2m widget, Django 1.11 compatible

Small fix to make https://www.djangosnippets.org/snippets/1779/ compatible with Django 1.11 To use this you'll also need the javascript from https://www.djangosnippets.org/snippets/1780/ I added an overridden optgroups method that can handle the additional tuple and a couple minor things I gathered while investigating for a fix (a default level_indicator of "+--" and changed paths for the JS files. All credits goes to @anentropic :-)

  • widget
  • mptt
Read More

django-mptt enabled replacement for SelectBox.js

This snippet is used in conjunction with the code in [#1779](http://www.djangosnippets.org/snippets/1779/) to make an mptt-enabled version of the FilteredSelectMultiple widget. See my blog for full details: [http://anentropic.wordpress.com](http://anentropic.wordpress.com/2009/11/05/more-django-mptt-goodness-filteredselectmultiple-m2m-widget/)

  • widget
  • mptt
Read More

django-mptt enabled FilteredSelectMultiple m2m widget

If you are using django-mptt to manage content (eg heirarchical categories) then it needs a bit of help to make a nice admin interface. For many-to-many fields, Django provides the quite nice FilteredSelectMultiple widget (a two-pane selection list with search box) but it only renders 'flat' lists... if you have a big category tree it's going to be confusing to know what belongs to what. Also, list items are sorted alphabetically in the js, which won't be what you want. This snippet extends FilteredSelectMultiple to show the tree structure in the list. You'll also need the js from this snippet: [#1780](http://www.djangosnippets.org/snippets/1780/) For usage details see my blog at: [http://anentropic.wordpress.com](http://anentropic.wordpress.com/2009/11/05/more-django-mptt-goodness-filteredselectmultiple-m2m-widget/)

  • widget
  • mptt
Read More

MPTTModelAdmin

This builds on a couple of other people's hacks to effectively manage django-mptt models via the admin. One problem you find is if you use the actions drop-down menu to ‘delete selected’ items from your mptt model… the bulk actions bypass the model’s delete method so your left/right values for the tree aren’t updated. What you need is a way to automatically rebuild the tree after a bulk action. This code provides that facility. Full details on my blog: [http://anentropic.wordpress.com/2009/10/26/](http://anentropic.wordpress.com/2009/10/26/making-admin-bulk-delete-action-work-with-django-mptt/)

  • admin
  • mptt
Read More

5 snippets posted so far.