Fix Python – django test app error – Got an error creating the test database: permission denied to create database

When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command):
python manage.py test appname

I get this error:
Creating test database for alias ‘default’…
Got an error creating the test database: permission denied to create database

Type ‘yes’ if you would like to try deleting the….

Fix Python – DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

I got a lot of errors with the message :
“DatabaseError: current transaction is aborted, commands ignored until end of transaction block”

after changed from python-psycopg to python-psycopg2 as Django project’s database engine.
The code remains the same, just don’t know where those errors are from.
….

Fix Python – Can’t subtract offset-naive and offset-aware datetimes

I have a timezone aware timestamptz field in PostgreSQL. When I pull data from the table, I then want to subtract the time right now so I can get it’s age.
The problem I’m having is that both datetime.datetime.now() and datetime.datetime.utcnow() seem to return timezone unaware timestamps, which results in me getting this error:
TypeError: can’t s….