#30972: USERNAME_FIELD UniqueConstraint option
-------------------------------------+-------------------------------------
               Reporter:  IKermani   |          Owner:  nobody
                   Type:  New        |         Status:  new
  feature                            |
              Component:             |        Version:  2.2
  contrib.auth                       |       Keywords:  AbstractUser
               Severity:  Normal     |  UniqueConstraint
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I'm having a case that the User model {{{USERNAME_FIELD}}} is cellphone
 and at registration, cellphone should be verified with SMS OTP. Meanwhile,
 the User object should be created with {{{is_verified = False}}} , so in
 {{{Meta}}} class, I need a UniqueConstraint like the following code:

 {{{
 UniqueConstraint(fields=["cellphone"], condition=Q(is_verified=True),
 name="unique_is_active_cellphone")
 }}}

 Generally, I need to have the ability to create multiple users with the
 same username and have a unique ''Active'' or ''Verified'' in the system.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30972>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.e06620d0f9be779f54be48d7c77dc00b%40djangoproject.com.

Reply via email to