So I've updated django to 1.4.5 and postgres to 9.2.3 and psycopg2 to 2.4.6 . I runserver
and everything looks ok, but when i go to localhost:8000
i see the infamous 'current transaction aborted..' on request.session.save()
in sessions/middleware.py(36).
I ran syncdb
and migrate
, no errors or changes for that matter. I also added in 'DATABASES' - 'OPTIONS': {'autocommit': True, }, but still no help. And I also tried this:
from django.db import connection
connection._rollback()
in django shell.
I also tried to stop postgres with:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
And i get:
pg_ctl: server does not shut down
Running pg -ef|grep postgres
shows no hanging queries.
How can i resolve this block? How to find what causes it?
Answer: A summery of what i did to solve this error
I enabled sql logging:
DEBUG=True
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'django.utils.log.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
}
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'DEBUG',
},
}
}
This showed me all sql statements being executed, including the one causing Internal DB Error, which in my case was caused by django-axes(i upgraded it earlier to version 1.2.9).
django-axes requires certain tables to be created. Re-running syncdb didn't solve my problem b.c there was a change inside one of the tables (new field - username).
python manage.py sqlclear axes
- showed me what tables to drop, so i went to psql and did that. After which i ran again python manage.py syncdb
and got updated tables.
And then i found a bug inside __init__.py
of axes module, in get_version()
- wrong string formatting. Fixing that solved all this mess :)
Finally, a happy ending!