Re: Make ManyToMany fields support "to_field".

147 views
Skip to first unread message

Shai Berger

unread,
Jan 12, 2016, 4:22:34 PM1/12/16
to django-d...@googlegroups.com
On Tuesday 12 January 2016 21:38:09 Luis Masuelli wrote:
> Currently, if I want to create a ManyToMany relationship, I'm stuck with
> two options:
>
>
> - Accept the by-default configuration. This will imply the inner table
> will have two fields based on the respective PKs.
> - Create a through-model. I will be able to specify two foreign keys,
> one for each table. I will lose the ability to cal .add and .delete.
>
> Is there a chance to let the user specify custom to_field (and say,
> "from_field") in a M2M field? I think it would be a nice feature, as we
> already allow them in FK and O2O fields.

Personally, I'd like it better if add() could still be used with an explicit
through model, provided that instances of the through model could be created
using only the two FK values -- applying limitations only where they are
actually needed on one hand, and keeping a clean separation between the
default, implicit thruogh model on one hand, and all the customizations and
configurations you can imagine on the other hand.

My 2 cents,
Shai.

Anssi Kääriäinen

unread,
Jan 13, 2016, 1:01:47 AM1/13/16
to django-d...@googlegroups.com
On Tue, Jan 12, 2016 at 11:22 PM, Shai Berger <sh...@platonix.com> wrote:
> Personally, I'd like it better if add() could still be used with an explicit
> through model, provided that instances of the through model could be created
> using only the two FK values

+1

- Anssi
Reply all
Reply to author
Forward
0 new messages