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) form.py from django import forms from .models import Contact from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from django.contrib.auth import get_user_model User = get_user_model () class CustomCreationForm (UserCreationForm): pass views.py from django.shortcuts import render from .forms import UserCreationForm from .forms import ContactForm from django.shortcuts import get_object_or_404, render, redirect, get_object_or_404 # import courier from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required, permission_required from django.contrib.auth import authenticate, login from .forms import ContactForm, CustomCreationForm # ********************** from django.contrib.auth import get_user_model User = get_user_model () def record (request): #def record (request): data = { 'form': CustomCreationForm () } form = CustomCreationForm (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 AttributeError at / record / Manager isn't available; 'auth.User' has been swapped for 'profiles.UserProfile' -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa3cc9d6-8085-4713-ad10-266dc62b6aa3n%40googlegroups.com.