I am using django and trying to create a registration form and below are my codes
forms.py
from django import forms
attrs_dict = { 'class': 'required' }
class RegistrationForm(forms.Form):
username = forms.RegexField(regex=r'^\w+$',
max_length=30,
widget=forms.TextInput(attrs=attrs_dict),
label=_(u'username'))
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,maxlength=75)),
label=_(u'email address'))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
label=_(u'password'))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
label=_(u'password (again)'))
views.py
from authentication.forms import RegistrationForm
def register(request):
regsiter_form = RegistrationForm()
if request.method=='POST':
form = regsiter_form(request.POST)
if form.is_valid():
new_user = User.objects.create_user(username=request.POST['username'],
email=request.POST['email'],
password=request.POST['password1'])
new_user.is_active = False
new_user.save()
return HttpResponseRedirect(reverse('index'))
return render_to_response('registration/registration_form.html'{'form':regsiter_form})
so when we go to the url,a registration form is displaying and when we enter the details and clicked submit i am getting the following error
TypeError at /accounts_register/register/
'RegistrationForm' object is not callable
Request Method: POST
Request URL: http://localhost:8000/accounts_register/register/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:
'RegistrationForm' object is not callable
Traceback
▶ Local vars
/home/user/package/authentication/views.py in register
form = regsiter_form(request.POST)
So can anyone please let me know why the above form object is complaining as the object is not callable and where we need to make the changes in order to avoid this error.