#17657: ModelForm does not respect ModelMultipleChoiceField's to_field_name
attribute
--------------------------------+------------------------------------
     Reporter:  andreyfedoseev  |                    Owner:  nobody
         Type:  Bug             |                   Status:  new
    Component:  Forms           |                  Version:  1.3
     Severity:  Normal          |               Resolution:
     Keywords:                  |             Triage Stage:  Accepted
    Has patch:  1               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  1
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+------------------------------------
Changes (by andreyfedoseev):

 * cc: andrey.fedoseev@… (added)


Comment:

 Unfortunately, the proposed patch doesn't work anymore. The original idea
 was to have `model_dict` to return "raw" values provided by
 `f.value_from_object()` and let the form fields to the rest. Now it's
 impossible because `ManyToManyField.value_from_object` was changed so that
 it always returns a list of `pk`s instead of a `QuerySet`. See
 
https://github.com/django/django/commit/67d984413c9540074e4fe6aa033081a35cf192bc

 I've created a new pull request GitHub with the following changes:

 1. Revert `ManyToManyField.value_from_obj` back to return a `QuerySet`
 instead of a list of `pk`s
 2. Remove the obsolete tests for `model_to_dict` performance optimization.
 3. Add tests to ensure that `to_field_name` is handled correctly.



 I don't know why the special case with `pk`s existed in `model_to_dict` in
 the first place.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.65fd6215555b47a173894e8f84bba8a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to