Django: How to access session data from inside a FormView in

1. Add get_form_kwargs() to your FormView in
class RegistrationFormView(FormView):
    template_name = 'registration/registration_form.html'
    form_class = RegistrationForm
    success_url = 'results'
    def get_form_kwargs(self):
        kwargs = super(RegistrationFormView, self).get_form_kwargs()
            'request': self.request
        return kwargs
2. Change __init__ in your to include request as a parameter:
def __init__(self, request, *args, **kwargs):
        super(RegistrationForm, self).__init__(*args, **kwargs)
3. Access your session data:
© 2011 Adam Gerson.