Opened 10 years ago

Closed 7 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 by Loic Bistuer, 10 years ago

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 by Adam Bogdał, 8 years ago

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

comment:4 by Simon Charette, 8 years ago

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

The patch is looking but it's missing tests.

comment:5 by Adam Bogdał, 8 years ago

Patch needs improvement: unset

Tests were added.

comment:6 by Tim Graham, 8 years ago

Needs tests: unset

comment:7 by Markus Holtermann, 8 years ago

Needs tests: set
Patch needs improvement: set

Patch lacks support for Q objects which are supported in limit_choices_to

comment:8 by Tim Graham, 8 years ago

Needs tests: unset
Patch needs improvement: unset

comment:9 by Tim Graham <timograham@…>, 7 years ago

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