Here's the error I'm getting:
{{{
ValueError: Lookup failed for model referenced by field
feedback.FeedbackItem.user: brambling.Person
}}}
This is bad on two fronts:
1. From the "brambling" side - the side declaring/using an AUTH_USER_MODEL
- I can't use the "feedback" module because it doesn't declare a
dependency on my model - and django doesn't currently support reverse
dependencies (unless they're undocumented.)
2. From the "feedback" side - the side with migrations and a swappable FK
- the app can't be used by anyone who actually has a swappable model,
because there's no way to declare a correct migration dependency.
I feel like the correct fix here would be to have a 'swappable
dependency'.
This is on stable/1.7.x
--
Ticket URL: <https://code.djangoproject.com/ticket/22874>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
Comment:
... wait, swappable dependencies are totally a thing. Okay. So why isn't
this working?
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:1>
Comment (by melinath):
It seems like this wasn't working because swappable dependency
automatically goes to the first migration in the swapped model's app - and
if the swappable model isn't migrated into existence in the first
migration, the swappable model dependency breaks.
I don't think this would be a serious problem in the future - brambling
has some slightly older 1.7 migrations, from back when it would generate a
million of them. I believe it's now consolidated down to one initial
migration, so most people probably won't run into this.
Workaround was to add a dependency to the last migration in the swappable
model's app. Would that work for the swappable model dependency behavior?
(I could also imagine situations where a swappable model is switched out
for a different one over the course of the app.)
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:2>
* version: 1.7-beta-2 => master
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:3>
Comment (by SmileyChris):
Reverse dependencies are possible, just not documented - use `run_before`
in the same way you use the `dependencies` attribute.
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:4>
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
This is a valid bug, not sure if it's considered release blocker - will
bump up and let andrew decide.
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:5>
Comment (by andrewgodwin):
One of the caveats we had to do to be able to support swappable models was
that they MUST be in the first migration of their respective app (as
you've seen, otherwise dependency problems occur). There's literally no
way to fix this, as it's logically impossible to construct a dependency
graph otherwise with our model.
I'll add documentation highlighting this next to the existing warning
about dependencies from unmigrated apps.
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"08221d1b5c1eec782c792818a2aa4a74ca7f1fcb"]:
{{{
#!CommitTicketReference repository=""
revision="08221d1b5c1eec782c792818a2aa4a74ca7f1fcb"
Fixed #22874: Document that AUTH_USER_MODEL must be in first migration
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:7>
Comment (by Andrew Godwin <andrew@…>):
In [changeset:"44b00af9bc3e6e8a561103aa5ca564995ca3c594"]:
{{{
#!CommitTicketReference repository=""
revision="44b00af9bc3e6e8a561103aa5ca564995ca3c594"
[1.7.x] Fixed #22874: Document that AUTH_USER_MODEL must be in first
migration
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:8>