[Django]-Pass kwarg into an inlineformset_factory?

2👍

You are passing the request to the formset and not to the forms in the formset, hence you get the error. For passing custom parameters to the formsets forms [Django docs] you need to pass a form_kwargs parameter to the formset:

class SummativeScoreFormView(
    LoginRequiredMixin,
    UserIsObserverOrObserveeMixin,
    SingleObjectMixin,
    FormView,
):
    ...
    
    def get_form_kwargs(self):
        kwargs = super().get_form_kwargs()
        kwargs['form_kwargs'] = {'request': self.request}
        return kwargs

Leave a comment