I have seen several posts and read the documentation about how it's best practice to set AUTH_USER_MODEL
in settings.py, but do not see any actual examples on how to do that. I have tried several configurations but keep getting this error:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed
It doesn't even tell me where the error is occurring. Below are the methods I have tried:
METHOD 1:
from django.contrib.auth import get_user_model
User = get_user_model()
Then I would just reference my user like this:
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
METHOD 2:
from django.contrib.auth.models import User
Neither worked, and I'm not sure how I would set AUTH_USER_MODEL
in settings.py if I just want to use the standard user model. I'm not customizing the User object at all. I assume something like AUTH_USER_MODEL = 'django.contrib.auth.models.User'
but I'm not sure.
Now I'm getting this:
AttributeError: 'str' object has no attribute '_meta'
users/forms.py
from django import forms
from django.conf import settings
from django.contrib.auth.forms import UserCreationForm
from .models import Profile
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = settings.AUTH_USER_MODEL
fields = ['username', 'email', 'password1', 'password2']
class UserUpdateForm(forms.ModelForm):
email = forms.EmailField()
class Meta:
model = settings.AUTH_USER_MODEL
fields = ['username', 'email']