How to make email field unique in model User from contrib.auth in Django

后端 未结 19 2115
夕颜
夕颜 2020-11-27 11:47

I need to patch the standard User model of contrib.auth by ensuring the email field entry is unique:

User._meta.fields[4].unique = True
<         


        
19条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 12:13

    Since version 1.2 (May 11th, 2015) there has been a way to dynamically import any chosen registration form using the settings option REGISTRATION_FORM.

    So, one could use something like this:

    REGISTRATION_FORM = 'registration.forms.RegistrationFormUniqueEmail'

    This is documented here.

    And here's the link to the changelog entry.

提交回复
热议问题