I have folder map looks like this: `` C:\Users\OS\oTree
- oTree | |-- nar2020 (this is the name of my app) | | | |-- templates. | | | |-- _init_.py | | | |-- models.py | | | |-- pages.py | | | |-- Procfile | | | |-- requirements.txt | | | |-- runtime.txt | |-- init_.py | |-- manage.py | |-- settings.py | |-- requirements_base.txt
(This is the standard format of Otree, if I move manage.py or settings.py into <nar2020> folder. the app cannot run in local host. And if I move Procfile, requirements.txt or runtime.txt to the outer folder (otree). I cannot push it in Heroku.So I cannot change the directoy of these files although I know that manage.py should be in the same folder with Procfile.
My manage.py file
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from otree.management.cli import execute_from_command_line
execute_from_command_line(sys.argv, script_file=__file__)
django.setup()
My Procfile
web: gunicorn oTree.manage:app --log-file –
My settings.py
from os import environ
SESSION_CONFIG_DEFAULTS = {
'real_world_currency_per_point': 1.00,
'participation_fee': 0.00,
'doc': "",
}
SESSION_CONFIGS = [
{
'name': 'nar2020',
'display_name': "nar2020",
'num_demo_participants': 1,
'app_sequence': ['nar2020'],
}
]
LANGUAGE_CODE = 'en'
REAL_WORLD_CURRENCY_CODE = 'EUR'
USE_POINTS = False
ROOMS = [
{
'name': 'nar2020',
'display_name': 'Room for live demo (no participant labels)',
}
]
STATIC_URL = '/static/'
AUTH_LEVEL = environ.get('OTREE_AUTH_LEVEL')
ADMIN_USERNAME = 'admin'
ADMIN_PASSWORD = environ.get('OTREE_ADMIN_PASSWORD')
DEBUG = (environ.get('OTREE_PRODUCTION') in {None, '', '0'})
SECRET_KEY = bla_bla_key'
INSTALLED_APPS = ['otree']
With this directory, I push to heroku with the directory is:"C:\Users\OS\oTree\nar2020" and it deployed.
But when I run *heroku run otree resetdb*
I got error as "cannot find oTree settings. Please cd to your oTree project folder, which contains a settings.file."
When I run *heroku run python manage.py migrate*
I got error as "python: can't open file 'manage.py': [Errno 2: No such file or directory]
As I may understood, because when I deploy heroku git push heroku master
with the directory is C:\Users\OS\oTree\nar2020 while the manage.py and setting.py are actually in C:\Users\OS\oTree (outside of the app folder) so it has errors. But I don't know how to make Heroku understand it. All of the case I found here is when manage.py and settings.py are in the lower level of the app. but I don't know how to solve with my case.
I tried
heroku config:set DJANGO_SETTINGS_MODULE=oTree.settings
. (But of course it does not work)I try to cd the directory back to C:\Users\OS\oTree and run
* heroku run python manage.py migrate*
. But I got the same error.In manage.py file. I move
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
out ofif __name__ == "__main__":
=> does not work
I stuck with them for many days. This is the first time I try to deploy Otree app on heroku. Could somebody help me to set the directory for setting.py file and manage.py file?