我在Django中制作用户注册表,但密码字段以原始格式显示密码,我想用点格式。 编码还没有完成,但它足以完成我想要的工作。 所以请理清我的问题。
model.py的代码是
from django.db import models
import datetime
from django.utils import timezone
class Registration(models.Model):
first_name=models.CharField(max_length=50)
last_name=models.CharField(max_length=50)
user_name=models.CharField(max_length=50)
password=models.CharField(max_length=50)
retype_password=models.CharField(max_length=50)
date_of_reg=models.DateTimeField('date published')
def __unicode__(self):
return self.first_name
def __unicode__(self):
return self.user_name
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
form.py的代码是
from django import forms
from django.core import validators
from models import Registration
class RegistrationForm(forms.Maniupulator):
def_init_(self):
self.fields=(
forms.PasswordField(field_name='password',
is_required=True),
forms.PasswordField(field_name='retype_password',
is_required=True,
validator_list=[validators.AlwaysMatchesOtherField('password',
'Passwords must match.')]),
)
和view.py是
from demo.registration.forms import Registration
from demo.registration.forms import RegistrationForm