Reputation: 752
I'm fairly new to Django. I have a form that I need to display, so I am using the FormView class. However, since I changed to using this class (I just had it as a normal function previously), I am getting an error:
__init__() takes exactly 1 argument (2 given)
At location:
/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/django/core/handlers/base.py in get_response, line 111
The traceback is simply:
response = callback(request, *callback_args, **callback_kwargs)
The relevant view is:
class HMFInput(FormView):
"""
The form for input.
"""
template_name = 'hmfform.html'
form_class = forms.HMFInput
success_url = '/hmf_finder/hmf_image_page/'
def form_valid(self,form):
canvas, file_object = utils.hmf_output(form)
self.request.session["canvas"] = canvas
self.request.session["text"] = file_object
return super(HMFInput,self).form_valid(form)
I tried to follow almost exactly the example from the documentation. Any idea what's going wrong?
EDIT: My urls.py
calls the view with the following:
url(r'^hmf_finder/$',
'hmf_finder.views.HMFInput',
name = 'HMF-input'),
Cheers.
Upvotes: 0
Views: 896
Reputation: 1937
Try this in urls.py:
from finder.views import HMFInput
url(r'^hmf_finder/$', HMFInput.as_view(), name = 'HMF-input'),
Upvotes: 1