[Fixed]-Recurring Order Modeling with Django

1👍

Tree-node-like models could be represented database-wise with a “parent” field pointing to the same model.

parent = models.ForeignKey('self', related_name='children')

However, caution is advised when you have to travel the “tree”, as you should load from databse all instances and then travel it in Python using some sort of data structure rather than accessing your database multiple times with the antipattern some_instance.parent.parent.parent.

Leave a comment