相关文章推荐
冷静的米饭  ·  获取元素和事件相关·  4 月前    · 
爱搭讪的大蒜  ·  Jira Data ...·  1 年前    · 
淡定的萝卜  ·  mac启动flask报错:zsh: ...·  1 年前    · 
Hi all,
I have defined several keys in PARTICIPANT_FIELDS in settings.py but keep getting the Application error (500) KeyError: 'variable_name' despite settings.py reading
PARTICIPANT_FIELDS = [
    'variable_name'
I am using the latest OTree version, running a local dev server, and need to debug this error. Do you have any pointers?
1) Curiously, print() statements --- even if added to lines in creating_session before I assign any keys --- fail to show up neither in the browser console in the terminal console. 
2) Secondly, I would like to ask if the PARTICIPANT_FIELDS have any restrictions on form or if I can assign any object (e.g. another object holding objects) as PARTICIPANT_FIELD?
Thanks for your help,
cheers
                
Hi Jana,
Would you mind sharing with us how this participant variable is coded in your _init_.py?
Shawn
yes sure, please point out a comma mistake, or coding error, I'd be very glad, I'm quite sure I must have messed something up. This assigns my participant variable `dfe_condition` class Subsession(BaseSubsession): def creating_session(subsession): if subsession.round_number == 1: for p in subsession.get_players(): participant = p.participant # for testing set this to true participant.dfe_condition = True (I *don't* use PyCharm but code it in Sublime Text, but this shouldn't matter.)
creating_session() is not a Subsession method, hence it should be placed outside of the class definition.
class Subsession(BaseSubsession):  
def creating_session(subsession):
    if subsession.round_number == 1:
      for p in subsession.get_players():
        participant = p.participant
        # for testing set this to true
        participant.dfe_condition = True
This kind of errors are prevented by oTree Studio. I would encourage you to give it a try.