Opened 9 years ago

Closed 6 years ago

#24195 closed Bug (fixed)

Changing limit_choices_to in a ForeignKey doesn't create a migration

Reported by: Aymeric Augustin Owned by: Adam Bogdał
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I thought that changing any attribute of a field — even help_text which obviously has no effect on the database schema — required creating a migration.

However, when I added limit_choices_to to a ForeignKey, makemigrations didn't detect any changes. This is inconsistent. I suspect it's a bug.

Change History (9)

comment:1 Changed 9 years ago by Loic Bistuer

Triage Stage: UnreviewedAccepted

Indeed, it's missing from ForeignObject.deconstruct() and ManyToManyField.deconstruct().

RelatedField the common parent of ForeignObject and ManyToManyField doesn't have a deconstruct() method, since all related fields share some common options such as limit_choices_to, related_name, etc. maybe this is a good opportunity to refactor.

comment:2 Changed 7 years ago by Adam Bogdał

Owner: changed from nobody to Adam Bogdał
Status: newassigned

comment:3 Changed 7 years ago by Adam Bogdał

Has patch: set

comment:4 Changed 7 years ago by Simon Charette

Needs tests: set
Patch needs improvement: set
Version: 1.7master

The patch is looking but it's missing tests.

comment:5 Changed 7 years ago by Adam Bogdał

Patch needs improvement: unset

Tests were added.

comment:6 Changed 7 years ago by Tim Graham

Needs tests: unset

comment:7 Changed 7 years ago by Markus Holtermann

Needs tests: set
Patch needs improvement: set

Patch lacks support for Q objects which are supported in limit_choices_to

comment:8 Changed 7 years ago by Tim Graham

Needs tests: unset
Patch needs improvement: unset

comment:9 Changed 6 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In cd2fe82:

Fixed #24195 -- Deconstructed the limit_choices_to option of related fields.

Migrations will now be created for changes to limit_choices_to.

Note: See TracTickets for help on using tickets.
Back to Top