Two forms in one template.

42 views
Skip to first unread message

Mike Ru

unread,
Nov 14, 2017, 10:29:57 PM11/14/17
to Django users
How can I pass two forms(registration and login) in one template? I'm using 'registration' and it's using different templates. For registration it's using 'registration_form.html and for login it's using login.html. How can I pass a login form in modal window inside registration_form.html. In short, I have a page for registration. It has a modal window. I need to pass in modal window only form for login. How can I make it ?

Ege Güneş

unread,
Nov 15, 2017, 7:53:54 AM11/15/17
to django...@googlegroups.com
You need to render your template with two forms in context. For example:

class LoginFormView(views.View):
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["login_form"] = LoginForm()
        context["registration_form"] = RegistrationForm()
        return context
On Wed, Nov 15, 2017 at 6:29 AM, Mike Ru <googlo...@gmail.com> wrote:
How can I pass two forms(registration and login) in one template? I'm using 'registration' and it's using different templates. For registration it's using 'registration_form.html and for login it's using login.html. How can I pass a login form in modal window inside registration_form.html. In short, I have a page for registration. It has a modal window. I need to pass in modal window only form for login. How can I make it ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/65c476e9-cfe6-4bf8-b8f2-30901db03e92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Ru

unread,
Nov 15, 2017, 5:55:22 PM11/15/17
to Django users
Thank you so much!

среда, 15 ноября 2017 г., 6:29:57 UTC+3 пользователь Mike Ru написал:
Reply all
Reply to author
Forward
0 new messages