Jumping in here, there have already been a couple threads on this forum from one or two people who have implemented this. You might find some useful information in them.
See:
I am trying to set up a custom user that will use email as the field for loggin in and authentication but also have the user name as an optional field. So I have set up the user model like so
from django.db import models
from django.contrib.auth.models import AbstractUser, BaseUserManager
from django.utils.translation import ugettext_lazy as _
class CustomUserManager(BaseUserManager):
"""Define a model manager for User model with no username field."""
def _create_user(self, username, …
Hello Guys, i found some thread online, and i tried more than once and failed, i think its easy overall but i am still locked :S
Trying to authenticate users with either email or username.
When i say Users i got a custom user, base user + profile with just a few more info about the user submitted through registration form:
class ProfiloUtente(models.Model):
user = models.OneToOneField(User, related_name=‘profile’, on_delete=models.CASCADE)
utente = models.ForeignKey(Utente, on_delete=models…
i’m struggling a bit with this problem, some says i have to override AuthenticationForm but i don’t know how cause i got a custom user registration and login, i’ll post it:
urls.py
urlpatterns = [
path('login/', LoginView.as_view(), {'template_name': 'accounts/login.html'}, name='login'),
Note im using default loginview right now.
So in views.py i must have this
def login(request):
return render(request, '/login.html')
...
...
Of course login.html is just like this
<div class='c…
1 Like