我已经创建了一个自定义注册表格。 '占位符'属性适用于用户名和电子邮件。但这不适用于我提到的“ forms.PasswordInput”的password1和password2。
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from .models import CustomUser
class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm):
model = CustomUser
exclude=()
widgets = {'username': forms.TextInput(attrs={'placeholder':'Username','class':'inputData'}),
'email': forms.TextInput(attrs={'placeholder': 'Email', 'class': 'inputData'}),
'password1': forms.PasswordInput(attrs={'placeholder': 'Password', 'class': 'inputData'}),
'password2': forms.PasswordInput(attrs={'placeholder': 'Confirm Password', 'class': 'inputData'})}