0

I'm using django-formtools and I have the following scenario:

class CreateCampaign(NamedUrlSessionWizardView):

    condition_dict={'rewards':show_reward_form,
            'user_conditionals':show_conditionals_form,
            'organizer_info': show_organizer_info_form(self.request.user)}

    def get_template_names(self):
        return [TEMPLATES[self.steps.current]]
    ....

As you can see I need to pass the currently logged in user to the show_organizer_form() function via the request object. How can I access the request object in this case?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Joe Jean JJ
  • 79
  • 10

1 Answers1

0

So, user apollo13 helped me on the django channel. Here is how the correct way looks:

condition_dict={
            'rewards':show_reward_form,
            'user_conditionals':show_conditionals_form,
            'organizer_info': lambda w:(show_organizer_info_form(w.request.user)),
        }

Note the use of lambda w.

Joe Jean JJ
  • 79
  • 10