Django: Make user email required
This video explains
Django: Make user email required
--
Become part of the top 3% of the developers by applying to Toptal
https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Question
01:28 Accepted answer (Score 10)
01:47 Answer 2 (Score 8)
02:02 Answer 3 (Score 1)
02:40 Thank you
--
Full question
https://stackoverflow.com/questions/4913...
Question links:
[docs]: https://docs.djangoproject.com/en/2.0/to...
[here]: https://docs.djangoproject.com/en/2.0/to...
Accepted answer links:
[https://code.djangoproject.com/ticket/29...]: https://code.djangoproject.com/ticket/29...
Answer 3 links:
[wrong]: https://docs.djangoproject.com/en/2.0/to...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django
#avk47
Django: Make user email required
--
Become part of the top 3% of the developers by applying to Toptal
https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Popsicle Puzzles
--
Chapters
00:00 Question
01:28 Accepted answer (Score 10)
01:47 Answer 2 (Score 8)
02:02 Answer 3 (Score 1)
02:40 Thank you
--
Full question
https://stackoverflow.com/questions/4913...
Question links:
[docs]: https://docs.djangoproject.com/en/2.0/to...
[here]: https://docs.djangoproject.com/en/2.0/to...
Accepted answer links:
[https://code.djangoproject.com/ticket/29...]: https://code.djangoproject.com/ticket/29...
Answer 3 links:
[wrong]: https://docs.djangoproject.com/en/2.0/to...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django
#avk47
ACCEPTED ANSWER
Score 12
I have to answer my question because now I know the solution:
The way I described in the start post should work. The docs are just wrong: https://code.djangoproject.com/ticket/29192
ANSWER 2
Score 11
add in models.py
from django.contrib.auth.models import User
User._meta.get_field('email')._unique = True
User._meta.get_field('email').blank = False
User._meta.get_field('email').null = False
ANSWER 3
Score 1
Edit: You have to subclass AbstractBaseUser and implement all other attributes too.
from django.contrib.auth.models import AbstractBaseUser, UserManager
class User(AbstractBaseUser):
email = models.EmailField(_('email address'), blank=False)
objects = UserManager()
Second edit:
Aliquis answer is the correct one. Current documentation is simply wrong: "It is an error to have fields in the abstract base class with the same name as those in the child (and Django will raise an exception)."