oTree Forum >

Creating/installing otree extensions

#1 by lborn

I am currently working on integrating a custom game into otree. For this, I would like to create a reusable Python package that can be installed in addition to otree to be able to quickly create studies with this game. In other extensions of otree, such as otree-redwood, the instruction mention adding the package to an `EXTENSION_APPS` list in the settings.py file. This apparently enabled the use of {{ extends "otree_redwood/Page.html" }} in templates. But at least in the newest version of otree, this seems to be no longer possible as the otree source code does not even seem to contain the string "EXTENSION_APPS". Also, looking at the source code, the paths considered for finding the templates seem to be limited to:

dirs = [
    Path('.'),  # for noself
    Path('_templates'),
    Path(otree.__file__).parent.joinpath('templates'),
] + [Path(app_name, 'templates') for app_name in settings.OTREE_APPS]

Which does not include templates defined in other installed python packages.

Is it still possible to include apps from installed Python packages? I was unable to find any relevant documentation on this matter. My current approach is to basically 'monkey-patch' the dirs attribute of otree.temlating.loader.ibis_loader when the extension package is initialized. But I don't think that this is a good solution.

Write a reply

Set forum username