Reputation: 3571
I have a form:
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)
And I want to use it with FormView
url(r'^megaform\/', FormView.as_view(form_class=ContactForm, success_url='/thanks/')),
Alas, I see the error:
TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
It says, that I haven't set the template to render my form with.
Is there a way to render the form without a custom template?
Upvotes: 0
Views: 1857
Reputation: 5048
no there isn't, you must specify a template, that could be something as simple as
<form action="" method="post" enctype="multipart/form-data">
{{ form.as_p }}
<input type="submit" value="send">
</form>
Upvotes: 3