Thanks for your advice, I was too busy to reply. I will learn to use a custom model. Thanks.
On Tuesday, January 27, 2015 at 2:36:53 PM UTC+8, James Schneider wrote: > > If you want any sort of enforcement of a unique email address at the > database level, you'll need a custom user model. If you don't care about > that, all you'd need to do is override the user forms and create a custom > clean_email function that checks for duplicates before saving the form > data. Not 100% guaranteed on a high traffic site unless you wrap it in a > transaction, and will become expensive to check as you gather more users in > the database, especially since the email field won't be indexed using the > standard user model, and would result in a slower string-matching query > against the entire table rather than an index-based comparison. > > If you have any special requirements for the user in your application, I > highly recommend you bite the bullet and create a custom user model. It's > not terribly difficult, and will better posture you down the road in the > event that your requirements change, not to mention you can enforce > uniqueness at the database level. > > -James > On Jan 26, 2015 7:01 PM, "Bruce Li" <[email protected] <javascript:>> > wrote: > >> To be more specific, I want the username and email in default user model >> both to be unique and not blank. >> >> On Tuesday, January 27, 2015 at 10:56:14 AM UTC+8, Bruce Li wrote: >>> >>> Hi, >>> >>> I want to build my user management based on default django users. But I >>> want emails to be unique as well. Is it possible to do that without the >>> need to create a custom user model and user managment? >>> >>> >>> Thanks, >>> - Bruce >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/e415b13a-2b38-4f1b-80e6-4ba808a09175%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/e415b13a-2b38-4f1b-80e6-4ba808a09175%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd69dcdb-607c-4377-b5b4-b24d5a63d1a4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

