Answer the question
In order to leave comments, you need to log in
How to override User model after migrations?
Migrations already applied (together with the django.contrib.auth application)
The project is working, but the auth.User model is not used anywhere yet, except, apparently, in the admin panel.
You need to override it by making registration only by email.
The problem is that janga is not designed for such a maneuver. I found some manuals, but there is not enough experience to figure it out.
Those. the plan, if I had started before migrating, would have been: User(AbstractBaseUser), USERNAME_FIELD='email', REQUIRED_FIELDS=[], didn't seem to have forgotten anything.
Answer the question
In order to leave comments, you need to log in
No one bothers you to inherit AbstractBaseUser with your own class like: CustomUser.
https://docs.djangoproject.com/en/2.0/topics/auth/...
And you can do authorization via email this way.
def auth(request):
email = request.POST['email']
password = request.POST['password']
get_user = get_object_or_404(User, email=email)
user = authenticate(username=get_user.username, password=password)
if user is not None and user.is_active:
login(request, user)
return HttpResponseRedirect(reverse('shop:index'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question