On 5/14/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 4/29/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
> > 2) I realize that there are historical (i.e.,
> > manipulator/pre-magic-removal related) reasons why reverse ForeignKey
> > and M2M relations are not contained on forms, but is there any reason
> > that newforms should continue the tradition?
> >
> > We probably don't want to include reverse fields on forms by default
> > (if only for backwards compatibility), but providing an optional
> > argument (say, reverse_fields=(...), containing a list of reverse
> > descriptor names) on form_for_model and form_for_instance would allow
> > users to easily include reverse relations on a form.
>
> Still, I think the concept of reverse_fields is too messy of an
> abstraction to be useful. There comes a point where it's not worth
> inventing frameworks on top of frameworks, and I think we're hitting a
> sweet spot pretty well right now, with the current form_for_model()
> and form_for_instance() implementations. (With the new "fields"
> parameter, it'll get just a bit closer to the sweet spot.) Supporting
> reverse relationships, in my mind, makes that sweet spot a bit more
> sour.

I agree with the general sentiment (i.e., keep the simple case
simple), but I'm not convinced it completely applies here - especially
in the case of m2m fields.

M2M fields are declared on one side of the relationship, but that
doesn't mean that it only makes sense to edit the relationship in one
direction. In my experience, it makes sense to be able to edit most
m2m relations from both directions. When editing a User, you want to
be able to set the Permissions for that User, and when editing a
Permission, you want to be able to set the Users that have that
Permission.

Even in those cases where uni-directional m2m editing makes sense,
there is no guarantee that the direction of definition matches the
direction of natural editing. For example, if you want have an m2m
relation between User and your model, you _must_ put the m2m
definition on your model, even if the natural editing direction is
from the User direction. Similar problems exist if you have to define
m2m relations in a particular order to avoid circular relations in
application dependencies.

To my mind, editing relations in both directions on a form is no
different to being able to query in both directions in a filter
statement.

In playing around with a possible implementation, I did come up with
one possible improvement on the original suggestion. Rather than
having a 'reverse_fields' option, allow reverse descriptor names in
the normal 'fields' argument. That way, the default form_for_model
wouldn't include reverse relations, but you can specify them if you
want them. Does this sound any less sour?

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to