double forms

24 views
Skip to first unread message

Andy Li

unread,
May 6, 2022, 12:12:07 PM5/6/22
to Django users
Hi I'm trying to put two forms, here is my code:
```
class FrontView(LoginRequiredMixin, UserPassesTestMixin, FormView):
template_name = "template.html"
form_class = FirstForm
coupon_form = SecondForm

def get_context_data(self, **kwargs):
kwargs['second_form'] = self.second_form
return super().get_context_data(**kwargs)
```
In the template I used {{ second_form }}. However it's not showing up.

Thanks.

Aditya Priyadarshi

unread,
May 8, 2022, 10:31:37 AM5/8/22
to Django users
Write the get_context_data like this
```
def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)
    context['second_form'] = self.second_form
    return context
```
Reply all
Reply to author
Forward
0 new messages