@transaction.atomic
def fill_subscription(form, event):
    reg = Registration(event=event)
    reg.first_name = form.cleaned_data["first_name"]
    reg.last_name = form.cleaned_data["last_name"]
    reg.email = form.cleaned_data["email"]
    reg.save()

    for question in event.eventquestion_set.all():
        if question.form_id() in form.cleaned_data:
            ans = Answer(registration=reg, question=question)
            ans.set_answer(form.cleaned_data[question.form_id()])
            ans.save()

    reg.calculate_price()
    reg.save()

    return reg
dataset/ETHPy150Open jonge-democraten/dyonisos/subscribe/forms.py/fill_subscription/original