How can I pass request.POST into my form?

I’m trying to pass request.POST into my form in views.py but I keep getting:

TypeError SetAsAssignment.init() got multiple values for argument ‘currentteacherid’

I’m not really sure where to go from here ://

views.py

def set_as_assignment(request, quiz_id):
        chosenquiz_id = quiz_id
        currentusername = request.user.username
        currentteacher = Teacher.objects.get(username=currentusername)
        currentid =  currentteacher.teacher_id 
        if request.method == "POST":
            set_as_assignment_form = SetAsAssignment(request.POST or None, currentteacherid=currentid)
            if set_as_assignment_form.is_valid():
                chosen_classes = request.POST.get('classes')
                class_codes = Class.objects.filter(class_name__in=chosen_classes).values_list('class_code', flat=True)
                for code in class_codes:
                    new_assignment = ClassQuiz(class_code=code, quiz_id=chosenquiz_id)
                    new_assignment.save()
        else:
             set_as_assignment_form = SetAsAssignment(currentteacherid=currentid)
        return render(request, 'set_as_assignment.html', {'set_as_assignment_form': set_as_assignment_form})

forms.py

class SetAsAssignment(forms.Form):

    def __init__(self, currentteacherid, *args, **kwargs):
        super(SetAsAssignment, self).__init__(*args, **kwargs)
        self.fields['classes'] = forms.MultipleChoiceField(choices = [(o.class_name, str(o)) for o in Class.objects.filter(teacher_id=currentteacherid)])

Thanks in advance :))

Please post the entire traceback for the error.

(post deleted by author)

I’m guessing some oddity in your data.

I’d suggest you either use a debugger or add some print statements to that view to print the values of chosenquiz_id, currentusername, currentteacher and currentid after they’re assigned. (Before the if request.method ... test.)

(post deleted by author)