"database connection isn't set to UTC" and Server Error (500) on otree hub

183 views
Skip to first unread message

Abcde

unread,
Jul 21, 2021, 10:19:59 AM7/21/21
to oTree help & discussion
Dear all,

I got this error for a project that can be run normally locally: 
Server Error (500)
For security reasons, the error message is not displayed here. You can view it with one of the below techniques:

Delete the OTREE_PRODUCTION environment variable and reload this page
Look at your Sentry messages (see the docs on how to enable Sentry)
Look at the server logs

The part of settings.py that I think is relevant:
#################
import os
from os import environ
import dj_database_url
import otree.settings


# to activate sentry
SENTRY_DSN = ...
# if you set a property in SESSION_CONFIG_DEFAULTS, it will be inherited by all configs
# in SESSION_CONFIGS, except those that explicitly override it.
# the session config can be accessed from methods in your apps as self.session.config,
# e.g. self.session.config['participation_fee']

SESSION_CONFIG_DEFAULTS = {
    'real_world_currency_per_point': 1.00,
    'participation_fee': 2.50,
    'doc': "",
}


SESSION_CONFIGS = [
...
]
# see the end of this file for the inactive session configs


# ISO-639 code
# '''
# LANGUAGE_CODE = 'de' # for example: de, fr, ja, ko, zh-hans
# REAL_WORLD_CURRENCY_CODE = 'EUR' # e.g. EUR, GBP, CNY, JPY
# USE_POINTS = False
# '''
LANGUAGE_CODE = 'en'
REAL_WORLD_CURRENCY_CODE = 'GBP' # e.g. EUR, GBP, CNY, JPY
USE_POINTS = False


ROOM_DEFAULTS = {}

ROOMS = [
    {
        'name': 'Experiment',
        'display_name': 'Experiment',
    },
]


# for flexibility, you can set it in the environment variable OTREE_AUTH_LEVEL
AUTH_LEVEL = environ.get('OTREE_AUTH_LEVEL')

ADMIN_USERNAME = 'admin'
# for security, best to set admin password in an environment variable
ADMIN_PASSWORD = environ.get('OTREE_ADMIN_PASSWORD')


# Consider '', None, and '0' to be empty/false
DEBUG = (environ.get('OTREE_PRODUCTION') in {None, '', '0'})


...
BASE_DIR = os.path.dirname(os.path.abspath(__file__))

# if an app is included in SESSION_CONFIGS, you don't need to list it here
INSTALLED_APPS = ['otree']

otree.settings.augment_settings(globals())

#######################################

When I change this line "DEBUG = (environ.get('OTREE_PRODUCTION') in {None, '', '0'})"
to: "DEBUG = (environ.get('OTREE_PRODUCTION') in {None, '', '1'})"
or "DEBUG = (environ.get('OTREE_PRODUCTION') in {'1'})"
or 
if environ.get('OTREE_PRODUCTION'not in {None, '''0'}:
DEBUG = False
else:
DEBUG = True

This is the error: 
Request Method: GET
Django Version: 2.2.12
Exception Type: AssertionError
Exception Value:
database connection isn't set to UTC
Exception Location: /app/.heroku/python/lib/python3.7/site-packages/django/db/backends/postgresql/utils.py in utc_tzinfo_factory, line 6
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.7.10
Python Path:
['/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python37.zip',
 '/app/.heroku/python/lib/python3.7',
 '/app/.heroku/python/lib/python3.7/lib-dynload',
 '/app/.heroku/python/lib/python3.7/site-packages']
Server time: Wed, 21 Jul 2021 16:11:33 +0200

Chris @ oTree

unread,
Jul 21, 2021, 10:47:14 AM7/21/21
to Abcde, oTree help & discussion
Try searching that error message on this list. You can solve it by upgrading oTree to the latest 3.x. 

Sent from my phone

On Jul 21, 2021, at 8:28 AM, Abcde <tuo...@gmail.com> wrote:

Dear all,
--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/ec18e75b-3fc4-4224-9379-6e39e8ed7fd2n%40googlegroups.com.

Abcde

unread,
Jul 21, 2021, 11:15:13 AM7/21/21
to oTree help & discussion
My otree is already the newest version.

Chris @ oTree

unread,
Jul 21, 2021, 11:23:53 AM7/21/21
to Abcde, oTree help & discussion
Take a look at your requirements.txt. If you are managing that file manually you need to change the psycopg2 version. See my previous notes on this mailing list. 

Sent from my phone

On Jul 21, 2021, at 9:15 AM, Abcde <tuo...@gmail.com> wrote:

My otree is already the newest version.

Abcde

unread,
Jul 21, 2021, 2:53:18 PM7/21/21
to oTree help & discussion
Thank you.

BonnEconLab

unread,
Apr 28, 2022, 3:50:49 AM4/28/22
to oTree help & discussion
I have encountered this issue when setting up oTree 3.1.0 for an experimenter on an Ubuntu server. Downgrading psycopg2 to version 2.8 (via pip install psycopg2==2.8) resolved the issue.
Reply all
Reply to author
Forward
0 new messages