I have a login/registration template (I am using Django) page with a tab for login and another for registration of new users. This means that I have two forms in one template. I am processing them using different views.
I created a forms.py where I put 2 classes like follows:
from django import forms
class LoginForm(forms.Form):
username = forms.CharField(label="Username", max_length=30, widget=forms.TextInput(
attrs={'name': "username",
'id': "username",
'tabindex': "2",
'class': "form-control",
'placeholder': 'Username'}))
password = forms.CharField(label="Password", widget=forms.PasswordInput(
attrs={'name': "password",
'id': "password",
'tabindex': "2",
'class': 'form-control',
'placeholder': 'Password'}))
class RegisterForm(forms.Form):
firstNameReg = forms.CharField(label="First Name", max_length=30, widget=forms.TextInput(
attrs={'name': "firstname",
'id': "firstname",
'tabindex': "1",
'class': "form-control",
'placeholder': 'First Name'}))
lastNameReg = forms.CharField(label="Last Name", widget=forms.TextInput(
attrs={'name': "lastname",
'id': "lastname",
'tabindex': "1",
'class': 'form-control',
'placeholder': 'Last Name'}))
usernameReg = forms.CharField(label="Username", max_length=30, widget=forms.TextInput(
attrs={'name': "username",
'id': "username",
'tabindex': "1",
'class': "form-control",
'placeholder': 'Username'}))
emailReg = forms.CharField(label="Email", max_length=30, widget=forms.EmailInput(
attrs={'name': "username",
'id': "username",
'tabindex': "1",
'class': "form-control",
'placeholder': 'Email'}))
emailRegConfirm = forms.CharField(label="Email", max_length=30, widget=forms.EmailInput(
attrs={'name': "username",
'id': "username",
'tabindex': "1",
'class': "form-control",
'placeholder': 'Confirm Email'}))
passwordReg = forms.CharField(label="Password", widget=forms.PasswordInput(
attrs={'name': "password",
'id': "password",
'tabindex': "2",
'class': 'form-control',
'placeholder': 'Password'}))
passwordRegConfirm = forms.CharField(label="Password", widget=forms.PasswordInput(
attrs={'name': "confirm-password",
'id': "confirm-password",
'tabindex': "2",
'class': 'form-control',
'placeholder': 'Confirm Email'}))
My issue is that in the template, it only sees the fields from the first class LoginForm (username and password) and ignores all the other fields. Any suggestions regarding this issue?
Aucun commentaire:
Enregistrer un commentaire