I have a Django form that is subclassed from the django-contact-form application. I want to supply an initial parameter to the form (which will vary depending on context).
This code returns the contact form fine, but obviously doesn't supply an initial parameter, so I need to extend it:
def contact_form(request):
scraper_form = scraperContactForm
return contact_views.contact_form(request=request, form_class=scraper_form)
This attempt to supply an initial parameter fails:
def contact_form(request):
scraper_form = scraperContactForm(initial={'title' : 'hello world'})
return contact_views.contact_form(request=request, form_class=scraper_form)
TypeError at /contact/
Keyword argument 'request' must be supplied
Hence, I have tried to supply a request argument, but weirdly, that fails by saying the form object is not callable:
def contact_form(request):
scraper_form = scraperContactForm(request=request, initial={'title' : 'hello world'})
# supply initial subject_dropdown field, if there's anything in the subject_type
return contact_views.contact_form(request=request, form_class=scraper_form)
TypeError at /contact/
'scraperContactForm' object is not callable
And no matter how I try to supply the request parameter, I keep on getting 'scraperContactForm' object is not callable
.
FYI, this is the code for my subclassed form:
class scraperContactForm(ContactForm):
subject_dropdown = django.forms.ChoiceField(label="Subject type", choices=(('suggestion', 'Suggestion for improvement'), ('bug', 'Report a bug'), ('other', 'Other')))
title = django.forms.CharField(widget=django.forms.TextInput(), label=u'Subject')
recipient_list = [settings.FEEDBACK_EMAIL]
Please can anyone suggest what's going wrong?