D
D
dashkevi4mike2015-06-21 16:42:00
Django
dashkevi4mike, 2015-06-21 16:42:00

Error with custom user model on django 1.8?

an error occurred when migrating a project from django 1.6 to django 1.8
i have a custom user model

class Profile(AbstractUser):
    middle_name = models.CharField(max_length=70, blank=True, verbose_name=_("Middle name"))
    gender = models.CharField(max_length=2, choices=GENDER_CHOICES)
    phone = models.CharField(max_length=150, blank=True, verbose_name=_("Phone"))
    status = models.CharField(max_length=500, blank=True, verbose_name=_("Status"))
    education = models.CharField(max_length=350, blank=True, verbose_name=_("Education"))
    progress_display = models.BooleanField(default=True, blank=True, verbose_name=_("Display progress"))
    about = models.TextField(blank=True, verbose_name=_("description about"))
    city = models.CharField(max_length=75, blank=True, verbose_name=_("City"))
    current_city = models.CharField(max_length=75, blank=True, verbose_name=_("Current city"))
    birth = models.DateTimeField(blank=True, null=True, verbose_name=_("Birthday"))
    registered = models.DateTimeField(auto_now=True, help_text=_('Registration date'),
                                      verbose_name=_("registration date"))
    is_teacher = models.BooleanField(default=False, blank=True, verbose_name=_("is_teacher"))
    hide_fields = models.CharField(max_length=255, blank=True)
    subscription = models.BooleanField(default=False, blank=True, verbose_name='Подписка на рассылку')
    main_photo = models.ForeignKey('avatar.Photo', blank=True, verbose_name=_("user main-photo"), related_name='avatar', default=None, null=True)

    class Meta:
        verbose_name = _('User')
        verbose_name_plural = _('Users')
        ordering = ('-registered', 'id')
        get_latest_by = 'registered'

All my applications are in a separate "applications" folder, the path to which I specify in settings.py like this:
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(BASE_DIR, 'applications'))

here I point to a link to a custom user model
AUTH_USER_MODEL = 'profile.Profile'
Here is my INSTALLED_APPS
INSTALLED_APPS = (
    'social',
    'photo',
    'profile',
    'qa',
    'main',
    'learn',
    'donate',
    'notifications',
    'articles',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.contenttypes',
    'grappelli',
    'django_extensions',
    'django.contrib.admin',
    'rest_framework',
    'djkombu',
    'autofixture',
    'crispy_forms'    
)

The "runserser", 'makemigrations' and 'migrate' commands work fine, but "createsuperuser" returns the following:
Traceback (most recent call last):
  File "/opt/pycharm-3.0.2/helpers/pycharm/django_manage.py", line 23, in <module>
    run_module(manage_file, None, '__main__', True)
  File "/usr/lib/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/camaro/programming/imedrese/master/manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 41, in load_command_class
    return module.Command()
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 28, in __init__
    self.UserModel = get_user_model()
  File "/home/camaro/programming/imedrese/master/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 155, in get_user_model
    "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 'profile.Profile' that has not been installed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-06-21
@sim3x

www.stackoverflow.com/a/26277254

V
Vov Vov, 2015-06-29
@balamut108

The model is not made according to the documentation: django.readthedocs.org/en/1.8.x/topics/auth/custom...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question