Why would it be a muti table inheritance? I would just inherit Car (class MyCar) and add the m2m field there, seems way more explicit and easy to understand too.
On Tue, May 8, 2018 at 12:18 PM Clayton D <[email protected]> wrote: > I posted a question on SO (https://stackoverflow.com/q/50222402/1978687), > but it's been viewed very few times so I'm hoping this is the right place > to get attention from those "in the know". The complete question (and > progress so far) is documented on SO so that's probably the best place to > answer. > > The essentials of the question are: > > - I need to create an M2M relationship between two models, but... > - The models are from external libraries (trivially User and Car) > - The models are non-abstract and multi-table inheritance would > introduce a ton of unnecessary overhead > - Others will use my code like (if not literally as) a 3rd party > library so I want to provide all of the usual magic methods for usability > -- e.g. Cars.objects.filter(users=user) -- which doesn't happen if I create > a manual M2M (i.e. "through") table. > > A commenter suggested using `add_to_class` on one of the 3rd party > models. It passes trivial test cases, but has hair and some of the magic > breaks because it's treated as a `through=` relationship even though it's a > trivial M2M table. > > I'm hoping someone who understands the ManyToMany implementation can tell > me if I can hijack the `contribute...` methods (or something similar) to > get this job done. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" 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]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/cc6f6c74-e5df-4fcf-b473-42f894fd3abb%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/cc6f6c74-e5df-4fcf-b473-42f894fd3abb%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" 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]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei1SzY12rvv%2BQsL9NP9yc_z%2BET6ZZD%2BssgmALHA43xtY%2BA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

