Google and trac both show nothing on this kind of functionality. I see that
contenttypes work like a Generic ForeignKey (many-to-one) but I don't see
anything about ManyToMany.
Is there any work being done by anyone on this kind of feature? I have some of
the details in mind, and if it isn't being worked on by anyone else, I had
planned on starting work on it.
Basically, the concept is that generic m2m relations would be no more
difficult than standard m2m relations:
class MyModel(models.Model):
content = models.GenericManyToManyField()
The content field would work like any other m2m field:
>>> m = MyModel()
>>> m2 = MyOtherModel()
>>> m3 = MyThirdModel()
>>> m.content.add(m2)
>>> m.content.add(m3)
>>> m.content
[<model 'MyOtherModel'>, <model 'MyThirdModel'>]
Is anyone else working on something like this? Thoughts?
--
Dave Sullivan
da...@dave-sullivan.com
647-235-0328
It's on my todo list -- I'm gonna need it for a project coming up in a
couple of months, at least -- but of course if you wanna take a crack
at it I'd love to let someone else do the work :)
Jacob
On Oct 12, 5:09 pm, "Jacob Kaplan-Moss" <jacob.kaplanm...@gmail.com>
wrote:
Thanks, I'd love to take a crack at it. I'll keep you posted about my
progress. Is there anything I need to do in terms of setting up a
project like this?
Post details on DjangoBranches and set up a branch on my own server,
or...?
It's not really a big deal -- should only be a small amount of code
(but writing the *right* code is the trick). I'd just do it as a patch
against django.contrib.contettpyes.
Myself, I use Mercurial and Mercurial Queues to manage patches of this
nature; some friends of mine use Git for the same purpose, and others
just use plain old SVN working dirs. YMMV, of course :)
Jacob
> It's not really a big deal -- should only be a small amount of code
> (but writing the *right* code is the trick). I'd just do it as a patch
> against django.contrib.contettpyes.
Yeah, I suppose it would be relatively small. The way I had in mind
was to create a GenericManyToManyField and a
GenericManyRelationManager. I think that's all that would be
required...