oTree Forum >

Internal server error

#1 by Anwesha (edited )

Hi there,

Hope you are well. I have recently completed coding my first treatment. And then started to code my survey. Everything seemed to be going well since I did not receive any error in my PyCharm. However, when I ran the survey using otree devserver, I get an error saying 'Internal Server Error'. I tried modifying the survey, such as taking out the questions with checkboxes, but I still keep getting the same error. I am giving some examples of the survey I have designed below:

class C(BaseConstants):
    NAME_IN_URL = 'survey'
    NUM_ROUNDS = 1
    job = [
        dict(name='pt', label="Yes, part time"),
        dict(name='ft', label="Yes, full time"),
        dict(name='no', label="No, I don't"),
        dict(name='benefit', label="Receive benefits/scholarships"),

class Subsession(BaseSubsession):

class Group(BaseGroup):

class Player(BasePlayer):
    age = models.StringField(
        choices=[['Less than 18'], ['18-24'], ['25-34'], ['35-44'], ['45-54'], ['Greater than 55'],
                 ['Prefer not to answer']],
        label='1. How old are you?',
    pt = models.BooleanField(blank=True)
    ft = models.BooleanField(blank=True)
    no = models.BooleanField(blank=True)
class Demographics(Page):
    form_model = 'player'
    form_fields = ['age']

class Job(Page):
    form_model = 'player'

    def get_form_fields(player: BasePlayer):
        return [lang['name'] for lang in C.job]

    def error_message(player: BasePlayer, values):
        # print('values is', values)
        num_selected = 0
        for lang in C.job:
            if values[lang['name']]:
                num_selected += 1
        if num_selected < 1:
            return "You must select at least 1 option."

page_sequence = [Demographics, Job]

#2 by Fanist

let the 'age' in Player field be:

class Player(BasePlayer):
    age = models.StringField(
        choices=['Less than 18', '18-24', '25-34', '35-44', '45-54', 'Greater than 55',
                 'Prefer not to answer'],
        label='1. How old are you?',

#3 by Anwesha

Thank you so much, it worked.

Write a reply

Set forum username