SelfForeignKey to prevent hierarchical loops
When you have a model containing a field that is a foreign key back to the same model, you could find yourself with a hierarchy with an infinite loop: #Data modelling Back to the Future > grandfather > father > son > father > ... Using this field instead of the standard ForeignKey will ensure that no model instance is saved that has itself as an ancestor, breaking the relationship if it does. (Enhancements: I am sure one would want to better enhance this with appropriate error handling instead of silently disconnecting the relationship. And the relevant forms ought not show ancestors in the field's widget to reduce the chances of this happening in the first place.)
- pre_save
- recursion
- loop
- foreign