Hey, it's been a number of years and I'd like to revisit this topic. I still consider it an anti-pattern to have __repr__ make a call to self.__unicode__ or self.__str__ as these can (and very often do) refer to related database objects. The last thing you want to happen while debugging a crash is for the mere act of observation to result in more database queries being executed. __repr__ is assumed to be safe to call by most debugging tools and is called by all crash reporting tools I've worked with. Having __repr__ itself crash (for example when the database connection is invalid) while handling an exception in a production environment can lead to exceptions being silently ignored or to misleading/useless stack traces being reported.
PS: Backwards compatibility was brought up as a potential issue but __repr__ is not usually an API consumed by application code. Cheers -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/097746a7-2eec-4390-9f29-200a5213b9dc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.