17 sep 07
I posted my first Django snippet today. Yes, it’s been a big week for both myself and Django. Usually I am just on the receiving end of open-source.
So, I’ll try to spare you database theory, but you can have database tables reference themselves (in Django, models), which means that if A points to B then A is B’s parent, which is incredibly useful for categories, children categories, grandchildren categories, etc. However, things can go awry if A points to itself, or if A points to B which points to A. If you have some code that follows these relationships to their end, it can result in what we in the biz call an infinite loop. I figured someone would have come up with some admin-side avoidance of this issue, but I didn’t find anything in my Google travels. So, I wrote an only moderately hackish validator to avoid the self-referencing foreign key problem.
On a personal note, it’s remarkable how hard it is to put code you’ve written out into the world for comment, yet I put words I’ve written out into the world for comment all the time.