-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django MPTT is no longer maintained - Migrate Existing Models to django-tree-queries
#510
Comments
Sounds like we really need to review for what, exactly, we're using MPTT, and how we can centralize the pattern. We already attacked this to some degree w/ the network model overhaul to decouple form Postgres using the MPTT pattern, but we could go deeper and make it more efficient by establishing some kind of base "tree" model that uses an adjacency list (self-referential foreign key) to a |
RequirementsThe main requirements, as I understand them are:
Non-requirements
Comparison of approachesBased on my limited research and understanding to date.
|
Naive implementation thoughtsItems 1 -3I believe that this is not as scary as it might sound at first. I know, I invoke this a lot and when it comes to comparing networks to other types of trees there are some built-in assumptions, but generally when it comes to MPTT you have the triangulation of Therefore all of the ancestors/descendants/membership queries shouldn't ever be all that expensive, because you will always have the 3-tuple (left, right, node) of the source object at query time. Item 4Seeing as this is just an optional annotation, this should also be pretty simple to do. Item 8This is going to vary based on how ordering is determined to be done. Obviously, again, with networks it's implied they will be numerical, but as you had hinted if it's done by |
A feature we don't have or use at present is an efficient way to annotate a queryset with the tree path (ordered list of ancestors) of each node in the queryset (versus individually annotating each instance with something like This would be useful for features like:
Perhaps django-tree-queries could add something like https://stevestedman.com/2012/02/generating-a-tree-path-with-a-cte/ as well? |
Another useful feature I've identified a potential need/benefit for is the ability to select a subtree and/or set of nodes based on ancestor properties - e.g. "get me all of the Locations who have an ancestor of type Campus", "get me the subtrees of Locations descended from Location ABC or Location XYZ", "get me the subtrees of Locations descended from a Location that is linked to Site PDQ".
|
django-tree-queries
Proposed Changes
The django-mptt project is no longer maintained so we need to find a new pattern for our tree use cases (Regions, rack groups, etc). I think we should revisit these use cases related to storage and access patterns to see if we really need the complexity of the MPTT structure, to begin with.
Justification
The django-mptt project is no longer maintained and as a core dependency, we need to find an alternative path.
TODO
Migrate
Footnote:
Region
is an MPTT model but should be collapsed intoLocation
sometime in this release and either this issue or that one can be the one to "turn the lights off" on MPTT (See: #2517)The text was updated successfully, but these errors were encountered: