#22563: Migration of admin.LogEntry.user fails. ---------------------------------+---------------------------------------- Reporter: efrinut@… | Owner: andrewgodwin Type: Bug | Status: new Component: Migrations | Version: 1.7-beta-2 Severity: Release blocker | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+----------------------------------------
Comment (by rockallite.wulf@…): Replying to [comment:20 Andrew Godwin <andrew@…>]: > In [changeset:"4535dedc42b90b8f75576e48a12e2e63d4e93048"]: > {{{ > #!CommitTicketReference repository="" revision="4535dedc42b90b8f75576e48a12e2e63d4e93048" > [1.7.x] Fixed #22563: Ignore AUTH_USER_MODEL errors in from_state > }}} Hi. I still get the error using Django 1.7b4 which contains the fix. I'm in the same situation with @dekkers. My custom user model {{{myapp.User}}} contains a foreign key to another model. When I run the migration, the error is raised. I looked into the traceback and see {{{django.db.migrations.operations.models.CreateModel}}} was invoking {{{to_state.render()}}} without the {{{ignore_swappable=True}}} argument, which caused the problem. I manually changed it to {{{to_state.render(ignore_swappable=True)}}}, then the migration was successfully executed. However, {{{./manage.py test}}} fails with the same error: {{{ValueError: Lookup failed for model referenced by field admin.LogEntry.user: myapp.User}}}, and this time in {{{django.db.migrations.executor}}} in {{{detect_soft_applied}}}... Perhaps a better fix is to change the signature of {{{django.db.migrations.state.ProjectState.render}}} to be invoked with {{{ignore_swappable=True}}} by default. I've looked into the code: {{{ def render(self, include_real=None, ignore_swappable=False): # ... Other code omitted ... if "%s.%s" % (lookup_model[0], lookup_model[1]) == settings.AUTH_USER_MODEL and ignore_swappable: continue }}} This is the only occurrence of the {{{ignore_swappable}}} parameter in the method body. So I think it isn't so bad to change {{{ignore_swappable}}} parameter to {{{True}}} by default. -- Ticket URL: <https://code.djangoproject.com/ticket/22563#comment:35> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/075.59d4235d4a682ee15b9e8022e152257d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.