Hi all. I have a project where I need to assign multiple models to each other via some many to many relationship.
There are a few main players in my prototype: Articles, Photos and Shows. Shows has many Articles and Photos. Article has many Photos, but has one Show. Photos has one Show, but has many Articles. (Might make more sense below) There will be more models involved in this process when this app goes to production, but these 3 will do for prototyping. My initial thought was to have an intermediate model with 2 generic relationships. I think this is going to be too costly in terms of performance as I'll need to run 2x the queries per lookup. One to check if my lookup object is referenced in the first generic relationship, then to see if its referenced in the 2nd one. The next idea was to have a self-referential m2m field for my models to inherit from. The issue there is the lookup returns objects whose type is that of the parent model, not the child model. I'm looking for a way to accomplish queries similar to this: >>> myshow <show4> >>> myshow.related.all() [<photo1>, <photo2>, <article3>, <article4>, <article9>] >>> photo1 = myshow.related.all()[0] >>> photo1.related.all() [<article3>, <show4>, <article9>, <article4>] The self referential model code I was using can be found at http://dpaste.com/119897/ and an ipython session at http://dpaste.com/119898/ . I feel as if I may be stretching what model inheritance was meant for or at least what its currently capable of. Although everyone says it, the solution will need to scale to a large number of users as it will be used in a very large dynamic-content site. This is the core of the content plan (to present various content types based on a given "pivot point", in the illustrated case above, shows). Looking for any advice or help you may be able to provide. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

