1. Django ProTip: __unicode__ and __getattr__ on Models

    Just ran into a really curious situation. django runserver was dying the moment I would try to access a model I was creating. Didn’t give me any error, didn’t raise and exception, just died.

    I opened up the console and checked, the value was in the database (objects.all().count() showed it).  Then I got the error with a stack trace.  I was causing a RuntimeError with a maximum recursion issue.

    Turns out, if you implement a __getattr__ method on your model you should also implement a __unicode__ to make sure that you don’t accidentally throw yourself into this loop.

    Lesson learned.  Hope it helps you.