Django-registration, force unique e-mail

前端 未结 7 1570
遇见更好的自我
遇见更好的自我 2020-12-03 14:32

Can I force users to make unique e-mail addresses in django-registration?

7条回答
  •  旧时难觅i
    2020-12-03 14:43

    As miku pointed out, you should simply use RegistrationFormUniqueEmail .

    If you implement according to the documentation and bug report replies (as of mid-2011), you'll probably end up with an exception like:

    TypeError at /accounts/register/
    register() takes at least 2 non-keyword arguments (1 given)
    

    your urlconf should look like this to properly specify this backend:

    (r'^accounts/register/', 'registration.views.register' {'form_class':RegistrationFormUniqueEmail, 'backend':'registration.backends.default.DefaultBackend' }),
    (r'^accounts/', include('registration.backends.default.urls')),
    

    [ please excuse the additional answer, as this belongs as a comment to miku's correct answer; I don't have the privilege of commenting, but this tip may save at least a few people 15 minutes each, so is hopefully worth the forced faux-pas ]

提交回复
热议问题