0

可能重复:
关于 D​​jango 中的字段类型的问题

我正在 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
4

0 回答 0