Reputation: 27969
This is a follow up question to this:
Postgres: More verbose error message: I am missing the table name
PostgreSQL 9.6 improved error messages with version 9.6.
With psql
you can enable it \set VERBOSITY verbose
.
How to enable this for every connection inside django ORM?
Background: I want better error messages.
Example: I am missing the table name in messages like this
IntegrityError: null value in column "date" violates not-null constraint
DETAIL: Failing row contains (10005, null, f, TEST, MAIL).
I think the relevant part of the 9.6 release notes is this:
Add support in libpq for regenerating an error message with a different verbosity level (Alex Shulgin)
This is done with the new function PQresultVerboseErrorMessage(). This supports psql's new \errverbose feature, and may be useful for other clients as well.
I use psycopg2 as database adapter.
Upvotes: 0
Views: 1947
Reputation: 11829
Try this
# settings.py
DATABASES = {
'default': {
'ENGINE': '...',
'OPTIONS': {
'init_command': "SET log_error_verbosity TO 'verbose'",
},
}
}
Test query
SELECT setting FROM pg_settings WHERE name = 'log_error_verbosity'
Upvotes: 4