oTree Forum >

Admin Report not working

#1 by Louis (edited )

Hi all,

I am currently trying to create a admin report page but it looks like the variables are not loaded.

This is also true if I implement the example from the documentation (https://otree.readthedocs.io/en/latest/admin.html?highlight=admin%20report#customizing-the-admin-interface-admin-reports).

I use:

class Subsession(BaseSubsession):
    def vars_for_admin_report(subsession):
        payoffs = sorted([p.payoff for p in subsession.get_players()])
        return dict(payoffs=payoffs)
And in admin_report.html:
<p>Here is the sorted list of payoffs in round {{ subsession.round_number }}</p>

    {{ for payoff in payoffs }}
        <li>{{ payoff }}</li>
    {{ endfor }}

I get the following error:
Application error (500)

UndefinedVariable: Cannot resolve the variable 'payoffs' (line 4, in "for")

If I only use the first line (with {{ subsession.round_number }}), this works correctly.
In this case, no variables are displayed (see attached photo).

Has anyone encountered the same problem?

Edit: I am using version 5.9.7, but it did also not work with older versions.


Write a reply

Set forum username