#1 by Sarah
Hello,
I want to choose one random round among 2 rounds to pay the participants accordingly. I tried with the provided code in the featured projects. Here is the code I used.
class Group(BaseGroup):
app_to_pay = models.StringField()
class Results(Page):
@staticmethod
def before_next_page(group: Group, timeout_happened):
import random
participant = group.participant
# print('participant.app_payoffs is', participant.app_payoffs)
apps = [
'round 1',
'round 2'
]
app_to_pay = random.choice(apps)
group.app_to_pay = app_to_pay
The problem is that I face an error: "group.app_to_pay is None. Accessing a null field is generally considered an error. Or, if this is intentional, use field_maybe_none()"
If I put initial in the app_to_pay=models.StringField(initial=''), then the error is gone but it shows nothing in the screen. Do you know how I can fix the error?
Best regards,
Sarah