Opened 11 years ago
Closed 8 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 , 11 years ago
| Triage Stage: | Unreviewed → Accepted | 
|---|
comment:2 by , 9 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → assigned | 
comment:4 by , 9 years ago
| Needs tests: | set | 
|---|---|
| Patch needs improvement: | set | 
| Version: | 1.7 → master | 
The patch is looking but it's missing tests.
comment:6 by , 9 years ago
| Needs tests: | unset | 
|---|
comment:7 by , 9 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 , 9 years ago
| Needs tests: | unset | 
|---|---|
| Patch needs improvement: | unset | 
  Note:
 See   TracTickets
 for help on using tickets.
    
Indeed, it's missing from
ForeignObject.deconstruct()andManyToManyField.deconstruct().RelatedFieldthe common parent ofForeignObjectandManyToManyFielddoesn't have adeconstruct()method, since all related fields share some common options such aslimit_choices_to,related_name, etc. maybe this is a good opportunity to refactor.