. Advertisement .
..3..
. Advertisement .
..4..
One of the most common error messages that you are likely to see is “AssertionError: Database connection isn’t set to UTC”. This error is thrown when the date on the server isn’t set to the Coordinated Universal Time. This error can sometimes be caused by daylight saving time changes. This blog will take you through an efficient solution on how you can try and fix this issue. Read on.
When Do You Get The Error “AssertionError: database connection isn’t set to UTC”?
An advanced, enterprise-class, open-source relational database system is PostgreSQL. Both SQL (relational) and JSON (non-relational) querying are supported by PostgreSQL. It is a very stable database with more than 20 years of open-source community development. Numerous web, mobile, and analytics applications use PostgreSQL as their primary database. When installing PostgreSQL on your server, you may get this error message.
raise AssertionError("database connection isn't set to UTC")
AssertionError: database connection isn't set to UTC
This can be your preference. You’d like to use timezone with py.
TIME_ZONE = ‘UTC’
USE_TZ = True
This error is caused by the most recent version of psycopg.
How To Fix The Error “AssertionError: database connection isn’t set to UTC”?
Approach 1: Downgrade psycopg2 to 2.8.6
This problem is caused by the most recent version of psycopg. So all we have to do now is downgrade psycopg2 to 2.8.6 to fix the problem. To do that, you can use the following command:
pip install psycopg2==2.8.6
Or
pip install psycopg2-binary==2.8.6
If you are utilizing poetry, you may change your version to 2.8.6 by typing poetry add [email protected].
Approach 2: Remove the following line
Excepting the above approach, there is another solution for you to solve the error “AssertionError: database connection isn’t set to UTC”. You just simply remove the following line from your settings.py file:
USE_TZ = True
Conclusion
We hope our blog post on how to solve the “AssertionError: database connection isn’t set to UTC” problem was useful. With this information, you should be able to handle this annoyance and a slew of other concerns when you design your application. Please leave a comment if you want to learn more about the topic or if you have any questions or ideas to share. Thank you for taking the time to read this!
Read more
Leave a comment