|
Posted by ognajd |
2010-03-04 16:58:07 - Can a Model contain a field which is effecitvely a list of Models, but not all of the Models of that type?
|
|
I have a model A which has a "Main Contact" which has a foreign key pointing to a Contact Model.
But there are other associated contacts that are important. I wanted to try have a list of Contact Models. But when I try to do this: contact_list = models.ManyToManyField(Contact,related_name="contact_list") it doesn't do what I thought it would; it just connects A to a list of ALL contacts which is not what I wanted. I basically want to have some sort of list where I can add contacts as I get them. Can Django do this, or am I missing some major point? Thanks! |
|
|
Posted by Herbert Poul ![]() |
2010-03-05 12:08:27 - Re: Can a Model contain a field which is effecitvely a list of Models, but not all of the Models of that type?
|
|
i'm not sure i understand what you need.. but if i understand it correctly you simply want to reference objects from different types? you should take a look at the content types with it's generic relations: http://docs.djangoproject.com/en/1.1/ref/contrib/contenttypes/#id1 .. although i fear it is only possible to use this for the 1 side of an 1:n relation - so you need another model to represent the list .. SCT - http://sct.sphene.net |



