Django Custom User Email Account Verification

前端 未结 2 1589
挽巷
挽巷 2020-12-12 11:43

I am looking to add email account verification in Django. I have attempted using the django-registration app to do so, but it doesn\'t appear that it has been updated to be

2条回答
  •  失恋的感觉
    2020-12-12 11:53

    You may also be interested in the simple but powerful django-verified-email-field.

    Simply use VerifiedEmailField in Your forms:

    from django import forms
    from verified_email_field.forms import VerifiedEmailField
    
    class RegistrationForm(forms.ModelForm):
        email = VerifiedEmailField(label='email', required=True)
    

    Or in Your models:

    from django.db import models
    from verified_email_field.models import VerifiedEmailField
    
    class User(models.Model):
        email = VerifiedEmailField('e-mail')
    

    It renders two input fields: e-mail and verification code. The verification code is sent to the e-mail address using AJAX or during field's clean if there is no valid code for given e-mail, so it works even without javascript.

提交回复
热议问题