[Django] #22874: Need a way to declare a dependency for AUTH_USER_MODEL.

25 views
Skip to first unread message

Django

unread,
Jun 19, 2014, 1:53:06 PM6/19/14
to django-...@googlegroups.com
#22874: Need a way to declare a dependency for AUTH_USER_MODEL.
----------------------------+------------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
Right now, it's impossible to declare a dependency to/from
AUTH_USER_MODEL.

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.

Django

unread,
Jun 19, 2014, 2:10:55 PM6/19/14
to django-...@googlegroups.com
#22874: Swappable dependency not working
----------------------------+--------------------------------------

Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by melinath):

* 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>

Django

unread,
Jun 19, 2014, 2:19:01 PM6/19/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
----------------------------+--------------------------------------

Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-beta-2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

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>

Django

unread,
Jun 19, 2014, 5:29:11 PM6/19/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
----------------------------+--------------------------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by SmileyChris):

* version: 1.7-beta-2 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/22874#comment:3>

Django

unread,
Jun 19, 2014, 5:34:57 PM6/19/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
----------------------------+--------------------------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

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>

Django

unread,
Jun 19, 2014, 5:37:35 PM6/19/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
---------------------------------+------------------------------------

Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
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
---------------------------------+------------------------------------
Changes (by SmileyChris):

* 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>

Django

unread,
Jun 20, 2014, 2:44:41 AM6/20/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
---------------------------------+------------------------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
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 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>

Django

unread,
Jun 20, 2014, 2:49:16 AM6/20/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
---------------------------------+------------------------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Andrew Godwin <andrew@…>):

* 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>

Django

unread,
Jun 20, 2014, 2:49:28 AM6/20/14
to django-...@googlegroups.com
#22874: Swappable dependency breaks if swappable model not in first migration of
its app
---------------------------------+------------------------------------
Reporter: melinath | Owner: nobody

Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Release blocker | Resolution: fixed
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 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>

Reply all
Reply to author
Forward
0 new messages