google-code-export / django-mptt

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

Allow select_related in model methods #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch allows to pass an extra keyword argument
"select_related" to the following methods:

- get_ancestors()
- get_children()
- get_descendants()
- get_next_sibling()
- get_previous_sibling()
- get_siblings()

and in the util function 'drilldown_tree_for_node()'.

It can reduce the number of queries in many usecases (eg: breadcrumbs,
menus, etc...).

Original issue reported on code.google.com by izimo...@gmail.com on 18 Dec 2009 at 1:42

Attachments:

GoogleCodeExporter commented 9 years ago
Can't you just do something like:

    n.get_descendants().select_related()

Unless I'm missing something, I'm not inclined to add this patch.

Original comment by craig.ds@gmail.com on 2 Sep 2010 at 1:17

GoogleCodeExporter commented 9 years ago

Original comment by craig.ds@gmail.com on 4 Sep 2010 at 1:55