Hello,

I'm trying to upgrade an app from Django 1.6 to 1.8 but I can't solve
a problem apparently related to a custom user model.

The project has an 'auth' app with its corresponding models.py and
apps.py. The snippet pasted bellow reproduces the problem which I
don't know how to fix.

Many TIA,
Norberto


# auth/models.py
from django.contrib.auth.models import AbstractUser
from django.db import models

class MyUser(AbstractUser):
    pass


# auth/apps.py
from django.apps import AppConfig

class MyAuth(AppConfig):
    name = 'auth'
    label = 'myauth'


# project/setting.py

INSTALLED_APPS = (
...
    'auth.apps.MyAuth',
...
)

AUTH_USER_MODEL = 'auth.MyUser'


Note apps.py is there just because 'auth' collides with django.contrib.auth.


$ ./manage.py makemigrations
Traceback (most recent call last):
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/apps/config.py",
line 159, in get_model
    return self.models[model_name.lower()]
KeyError: 'myuser'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/__init__.py",
line 351, in execute_from_command_line
    utility.execute()
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/__init__.py",
line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
line 444, in execute
    self.check()
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/management/base.py",
line 482, in check
    include_deployment_checks=include_deployment_checks,
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/core/checks/registry.py",
line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/contrib/auth/checks.py",
line 12, in check_user_model
    cls = apps.get_model(settings.AUTH_USER_MODEL)
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/apps/registry.py",
line 202, in get_model
    return self.get_app_config(app_label).get_model(model_name.lower())
  File 
"/home/ubuntu/.virtualenvs/testauth/lib/python3.4/site-packages/django/apps/config.py",
line 162, in get_model
    "App '%s' doesn't have a '%s' model." % (self.label, model_name))
LookupError: App 'auth' doesn't have a 'myuser' model.

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADut3oA31DiRXAUS52AZHnHY94EBAuAWamyTbGPHbwzbV%3DKwFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to