Opened 9 years ago
Closed 9 years ago
#26405 closed Bug (duplicate)
ModelMultipleChoiceField does not honor to_field_name at render
Reported by: | drepo | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.9 |
Severity: | Normal | Keywords: | model-forms |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Steps to reproduce:
1) Clone the repo (sample Django project which reproduces the bug) at https://github.com/drepo/model-multi-render
2) Install requirements.txt (preferably in a virtualenv)
3) Run the migrations
4) ./manage.py loaddata --app demo initial_data.json (Load fixtures -- sample data)
5) Visit http://localhost:8000/demo-working/1 -- Notice all items in contents are selected. This is expected.
6) Visit http://localhost:8000/demo/1 -- Notice all items in contents are unselected. This is NOT expected.
The difference between (5) and (6) is the form_class
used in the view for (6) uses a to_field_name
parameter which is not id
.
Python: 3.4,
Linux Mint 17,
Django 1.9.4
Duplicate of #17657.