1👍
Try remove redundant ‘context’ in your html, {{ context.form1 }} would incorrectly links to context['context']['form1']
which doesn’t exist.
<form action="" method="post">
{% csrf_token %}
{{ form1.as_p }}
<input type="submit">
</form>
<form action="" method="post">
{% csrf_token %}
{{ form2.as_p }}
<input type="submit">
</form>
0👍
-
Remove the useless
context
in your template, justform1.as_p
is fine.<form action="" method="post"> {% csrf_token %} {{ form1.as_p }} <input type="submit"> </form> <form action="" method="post"> {% csrf_token %} {{ form2.as_p }} <input type="submit"> </form>
-
You need to instantiate a form object and not passing the class in your context. Here, you are passing a class, and Django won’t be able to use it.
class MultipleFormView(TemplateView): template_name = 'blog/multiple_form.html' def get_context_data(self, **kwargs): context = super(MultipleFormView, self).get_context_data(**kwargs) context['form1'] = Form1() # <---- context['form2'] = Form2() # note the parenthesis here return context success_url = '/'
- [Answer]-Stack Overflow OAuth – Python Social Auth
- [Answer]-Django manage.py sqclear all apps
- [Answer]-Relational condition check in Django Rest Framework
- [Answer]-How to resolve Django tutorial migration error?
- [Answer]-Django using {{ MEDIA_URL }} in template with HttpResponse
Source:stackexchange.com