Greetings, I am starting in the world of django and I have some problems
with a custom user, for the registration of users to the database, the
example that I have works 100% with the user that comes by default allows
me to render the registration form user without any inconvenience, but when
I create a custom user the same screen for registration no longer works for
me, it no longer works for me, I have read a lot of the web but nothing
works for me. It should be something very simple, but I can't find what I
should do.
To make the change to a custom user, delete the database and the migration
that I had to create a clean database with the new model, but I have not
been able to do it.
models.py
from django.contrib.auth.models import AbstractUser
class UserProfile (AbstractBaseUser, PermissionsMixin):
# table template for system login users with E-mail
email = models.EmailField (max_length = 255, unique = True,
verbose_name = 'E-mail')
name = models.CharField (max_length = 200)
is_active = models.BooleanField (default = True)
is_staff = models.BooleanField (default = False)
views.py
from .forms import UserProfile
def record (request):
data = {
'form': UserProfile ()
}
form = UserProfile (data = request.POST)
if form.is_valid ():
form.save ()
#authentic at once
user = authenticate (username = form.cleaned_data ["email"],
password = form.cleaned_data ["password1"])
# I log in here
login (request, user)
#redirect home
messages.success (request, "Registered successfully")
return redirect (to = "home")
data ["form"] = form
return render (request, 'registration / registration.html', data)
setting.py
AUTH_USER_MODEL = 'profiles.UserProfile'
I repeat with the user model that comes by default from django, it works
100%
When running the server it throws me this error
TypeError at / record /
UserProfile () got an unexpected keyword argument 'data'
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/abe66834-8959-424a-bab4-ac4fdc3243c2n%40googlegroups.com.