I am running  Django 1.10.4 with Python 3.4.3, learning about Django.

I created a custom user model 'MyUser' copied from the Django docs at 
https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#substituting-a-custom-user-model;
 
 this works fine.

Then I renamed the model from 'MyUser' to 'TheUser', updating models.py, 
admin.py and settings.py and succesfully ran 'makemigrations'.  Then,  when 
I run 'migrate',  I get the traceback below.

If I temporarily comment the AUTH_USER_MODEL setting, makemigrations works 
fine, but as soon as I uncomment the AUTH_USER_MODEL setting again,  both 
'makemigrations' and 'migrate' fail with the same error and a similar 
traceback.
I did not do any additional changes to the model, so makemigrations and 
migrate should actually not do anything at this point.

Is this a bug?

I have attached a complete project that can be used to reproduce the 
problem.


$ python manage.py makemigrations
Did you rename the auth_by_email.MyUser model to TheUser? [y/N] y
Migrations for 'admin':
  
/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/contrib/admin/migrations/0003_auto_20161207_1018.py:
    - Alter field user on logentry
Migrations for 'auth_by_email':
  auth_by_email/migrations/0003_auto_20161207_1018.py:
    - Rename model MyUser to TheUser

$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, auth_by_email, contenttypes, sessions
Traceback (most recent call last):
  File "/home/johan/work/backend/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/core/management/__init__.py",
 
line 367, in execute_from_command_line
    utility.execute()
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/core/management/__init__.py",
 
line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/core/management/base.py",
 
line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/core/management/base.py",
 
line 345, in execute
    output = self.handle(*args, **options)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/core/management/commands/migrate.py",
 
line 164, in handle
    pre_migrate_apps = pre_migrate_state.apps
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/utils/functional.py",
 
line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/db/migrations/state.py",
 
line 176, in apps
    return StateApps(self.real_apps, self.models)
  File 
"/home/johan/Seafile/main/sikando/Projects/doclr/env/lib/python3.4/site-packages/django/db/migrations/state.py",
 
line 249, in __init__
    raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field admin.LogEntry.user was declared with a lazy 
reference to 'auth_by_email.theuser', but app 'auth_by_email' doesn't 
provide model 'theuser'.

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/3fe59036-fb3e-42ef-aa91-a440f3aac133%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: backend.tgz
Description: GNU Unix tar archive

Reply via email to