Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#10140 closed (invalid)

OneToOne fields in ModelForm

Reported by: mccartney Owned by: nobody
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently there's no support for OneToOne fields in ModelForms.
Either:

  • If this is by design, then it should be mentioned in the docs
  • Otherwise it should be implemented...

I test it running:

from django.forms.models import model_to_dict

myModelInstance = ModelClass()
myModelInstance.subEntity = SubEntity()
dikt = model_to_dict(myModelInstance())

One would expect dikt['subEntity'] to be a dictionary containing SubEntity() fields, not some id.

The ticket is related to #8015

Change History (2)

comment:1 by Karen Tracey, 16 years ago

Resolution: invalid
Status: newclosed

Huh?

If I search for model_to_dict in the Django docs I get no matches, so I'm not sure what it is supposed to do. It's apparently something used internally, OK, and maybe it's valid for app code to call it as well, but it's not currently part of the documented API.

If I try your sample code with some of my own models (since you provide no details of your models that would illustrate, for example where a OneToOne field comes into play) I get an error because this line:

dikt = model_to_dict(myModelInstance())

attempts to call a model instance, which is not callable. Now I could guess the () are not supposed to be there, but I'm going a little farther down the path tweaking things and filling in the blanks in attempting to figure out what it is you are trying to report as broken than I really should be.

So, if you care to try again, feel free to reopen this ticket but please include details of your models and how, exactly (preferably shown using documented APIs) there is no support for OneToOneFields in ModelForms.

(Also the ticket you link to was closed as a dup of another that was closed as fixed, so that doesn't shed any light for me. How is a current problem related to a fixed problem, particularly one one that only affected the admin, since you do not mention admin here at all?)

comment:2 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top