How to create password input field in django

前端 未结 9 633
春和景丽
春和景丽 2020-12-28 11:19

Hi I am using the django model class with some field and a password field. Instead of displaying regular plain text I want to display password input. I created a model class

9条回答
  •  粉色の甜心
    2020-12-28 12:05

    I did as a follow without any extra import

    from django import forms
    class Loginform(forms.Form):
        attrs = {
            "type": "password"
        }
        password = forms.CharField(widget=forms.TextInput(attrs=attrs))
    

    The idea comes form source code: https://docs.djangoproject.com/en/2.0/_modules/django/forms/fields/#CharField

提交回复
热议问题