AUTH_USER_MODEL should point to your model class, not the model admin
use
AUTH_USER_MODEL = 'user_text.User'
Assuming that the app where the User model lives is called "user_text"
On Sat, Jul 29, 2017 at 12:56 PM, Binny Zupnick <bzupnick@gmail.com> wrote:
I've tried many things, but I'll write what I currently have implemented.--admin.py
admin.site.register(User, UserAdmin)
models.py
class User(AbstractUser):
phone = models.CharField(max_length=40, unique=True)settings.py
AUTH_USER_MODEL = 'user_text.UserAdmin'I do `makemigrations` and I'm getting this error:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv )
File "/usr/local/lib/python2.7/dist-packages/django/core/ , line 363, in execute_from_command_linemanagement/__init__.py"
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/ , line 337, in executemanagement/__init__.py"
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__. , line 27, in setuppy"
apps.populate(settings.INSTALLED_APPS )
File "/usr/local/lib/python2.7/dist-packages/django/apps/ , line 108, in populateregistry.py"
app_config.import_models()
File "/usr/local/lib/python2.7/dist-packages/django/apps/ , line 202, in import_modelsconfig.py"
self.models_module = import_module(models_module_name )
File "/usr/lib/python2.7/importlib/__init__.py" , line 37, in import_module
__import__(name)
File "/home/binny/Development/politikal/user_text/models.py" , line 7, in <module>
from django.contrib.auth.admin import UserAdmin
File "/usr/local/lib/python2.7/dist-packages/django/contrib/ , line 7, in <module>auth/admin.py"
from django.contrib.auth.forms import (
File "/usr/local/lib/python2.7/dist-packages/django/contrib/ , line 22, in <module>auth/forms.py"
UserModel = get_user_model()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/ , line 198, in get_user_modelauth/__init__.py"
"AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured : AUTH_USER_MODEL refers to model 'user_text.UserAdmin' that has not been installed
Some nice people on the internet have advised to remove the `AUTH_USER_MODEL` line in `settings.py`. when I remove that line and run `makemigrations` I get:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
user_text.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
user_text.User.user_permissions : (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
I've been spending a day on this, am really lost, and would love some direction.
Thanks!
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+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ee778413- .2451-477a-9c98-408567ff41e7% 40googlegroups.com
For more options, visit https://groups.google.com/d/optout .
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei0LRNfu0bZ0TJAryZCOFjdfYB%2B1%3Dd%2BSE2E96tTOAzxG%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment