将此内容保存在
forms.py
from django import formsfrom django.contrib.auth.forms import AuthenticationFormfrom django.forms.widgets import PasswordInput, TextInputclass CustomAuthForm(AuthenticationForm): username = forms.CharField(widget=TextInput(attrs={'class':'validate','placeholder': 'Email'})) password = forms.CharField(widget=PasswordInput(attrs={'placeholder':'Password'}))
在您的主目录
urls.py(您的登录视图称为)中
from django.contrib.auth import views as auth_viewsfrom app.forms import CustomAuthFormurlpatterns = [url(r'^login/$', auth_views.login, name='login', kwargs={"authentication_form":CustomAuthForm}),]
我们在这里做的额外的事情是增加了kwargs
kwargs={"authentication_form":CustomAuthForm}
请使用它作为将来的参考
django.contrib.auth.views.LoginView和django.contrib.auth.forms.AuthenticationForm
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)