#29981: "Please correct the error below." (with no errors displayed) when 
changing
an inline that has a one-to-one relation to the parent that uses to_field
-------------------------------+-----------------------------------------
     Reporter:  Bernie         |                    Owner:  Patrik Sletmo
         Type:  Bug            |                   Status:  assigned
    Component:  contrib.admin  |                  Version:  2.1
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+-----------------------------------------

Comment (by Patrik Sletmo):

 Thanks Bernie!

 There is currently some code for correctly setting the to_field
 
[https://github.com/django/django/blob/ef87b38ef7b07a5a9b4ee424a04a9811836dee39/django/forms/models.py#L961
 here], but it appears that this only works for foreign key fields when
 they are not also the primary key of the contained model. The code linked
 above was introduced 10 years ago in
 
[https://github.com/django/django/commit/a00be663112bc674f71492717f7bbbb35b922e42
 this commit] and I'm beginning to wonder if the placement was incorrect
 back then.

 I've tried moving the linked if-statement outside of its surrounding
 block, and this seems to fix the issue while not breaking any existing
 test cases. I'll look through the code a bit more to see if this change
 introduces any issue or if there exist a better way of doing this. If this
 turns out to be a reasonable solution I'll make sure to submit a patch
 tomorrow.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29981#comment:5>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.86d9fce1227c4a97d42e7b9e2768063b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to