Roland van Laar <rol...@micite.net> writes: > I would like to know which Model and Field caused the error. > > Such as: DatabaseError: own_app.models.User.street: value too long for > type character varying(100).
This could be done by having Django's database interface catch the error, and chain a new exception from that one: try: pgsql_cursor.execute(foo) except pgsql.SpamException as exc: error = DatabaseError( "in {model_name}: {exc}".format( exc=exc, model_name=fully_qualified_model_name)) raise error from exc See PEP 3134 for the exception chaning syntax ‘raise foo from bar’ <URL:http://www.python.org/dev/peps/pep-3134/> which is now in Python <URL:http://docs.python.org/3/library/exceptions.html>. -- \ “I do not believe in forgiveness as it is preached by the | `\ church. We do not need the forgiveness of God, but of each | _o__) other and of ourselves.” —Robert G. Ingersoll | Ben Finney -- You received this message because you are subscribed to the Google Groups "Django developers" 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 http://groups.google.com/group/django-developers. For more options, visit https://groups.google.com/groups/opt_out.