[Django] #22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key

33 views
Skip to first unread message

Django

unread,
Jun 23, 2014, 1:06:32 PM6/23/14
to django-...@googlegroups.com
#22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key
-------------------------------------+-------------------------------------
Reporter: timo | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.7-beta-2
Component: | Keywords:
Migrations | Has patch: 0
Severity: Release | Needs tests: 0
blocker | Easy pickings: 0
Triage Stage: Accepted |
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
`to_field` shouldn't appear in the migration for a `ForeignKey` to
`settings.AUTH_USER_MODEL`, otherwise the migration isn't usable if
`settings.AUTH_USER_MODEL` uses a primary key with a name different than
'id'.

It's not necessary to include the field name, the default behavior of
models.ForeignKey is to look up the primary key field name from the target
model.

from [https://github.com/django/django/pull/2840 this pull request].

--
Ticket URL: <https://code.djangoproject.com/ticket/22889>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 23, 2014, 1:23:39 PM6/23/14
to django-...@googlegroups.com
#22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key
-------------------------------------+-------------------------------------
Reporter: timo | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version:
Component: Migrations | 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 Tim Graham <timograham@…>):

In [changeset:"68b89f4d13b69771b232c1fcb0fb598000b6eb98"]:
{{{
#!CommitTicketReference repository=""
revision="68b89f4d13b69771b232c1fcb0fb598000b6eb98"
[1.7.x] Removed 'to_field' from ForeignKey(settings.AUTH_USER_MODEL) in
admin's initial migration.

This enables using a custom user model with a primary key with a name
different than 'id'; refs #22889.

Backport of bcd2e6c697 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22889#comment:1>

Django

unread,
Jun 23, 2014, 11:40:27 PM6/23/14
to django-...@googlegroups.com
#22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key
-------------------------------------+-------------------------------------
Reporter: timo | Owner: nobody
Type: | Status: closed

Cleanup/optimization | Version:
Component: Migrations | 1.7-beta-2
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:"0b571753a89f2a7a34c76dea5ee81f821b980779"]:
{{{
#!CommitTicketReference repository=""
revision="0b571753a89f2a7a34c76dea5ee81f821b980779"
Fixed #22889: Unneeded to_field in fk.deconstruct causing swap issues
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22889#comment:2>

Django

unread,
Jun 23, 2014, 11:40:40 PM6/23/14
to django-...@googlegroups.com
#22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key
-------------------------------------+-------------------------------------
Reporter: timo | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version:
Component: Migrations | 1.7-beta-2
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:"e4c9ccdbb5295c952a0ca12f988ae1b2164b1623"]:
{{{
#!CommitTicketReference repository=""
revision="e4c9ccdbb5295c952a0ca12f988ae1b2164b1623"
[1.7.x] Fixed #22889: Unneeded to_field in fk.deconstruct causing swap
issues
}}}

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

Django

unread,
Apr 29, 2021, 2:16:31 AM4/29/21
to django-...@googlegroups.com
#22889: Proper handling of to_field in deconstruct for AUTH_USER_MODEL foreign key
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: nobody

Type: | Status: closed
Cleanup/optimization | Version:
Component: Migrations | 1.7-beta-2
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 Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ee3b719a81e62751195853233813c198ab7b66bb" ee3b719a]:
{{{
#!CommitTicketReference repository=""
revision="ee3b719a81e62751195853233813c198ab7b66bb"
Refs #32675 -- Removed to_field from ForeignKeys in contrib apps'
migrations.

Refs #22889.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/22889#comment:4>

Reply all
Reply to author
Forward
0 new messages