Re: Efficient access through two manytomany layers

2010-01-18 Thread Alastair Campbell
On Mon, Jan 18, 2010 at 5:25 PM, Alex Robbins wrote: > Hmm, you might also look at just doing something like > Event.objects.values_list > ('classes_involved__parent_disciplines__name', flat=True).distinct(). > That works on some relations, but I haven't tested it in your case. I tried that and a

Re: Efficient access through two manytomany layers

2010-01-18 Thread Alex Robbins
Probably need to solve the problem individually: First problem: Performance. Have you looked at using select_related[1] in your query? That might speed up the loop since it would do all the lookups in one big query. (It'll need more memory since it is loading it all at once, but it will probably b

Re: Efficient access through two manytomany layers

2010-01-18 Thread Alastair Campbell
On Mon, Jan 18, 2010 at 2:59 PM, Alex Robbins wrote: > Hmm, you posted the save method for your Event model, but not the > definition. I think you haven't gotten any feed back because no one > really knows what you are asking. Could you show the Event model, and > then show what a finished save sh

Re: Efficient access through two manytomany layers

2010-01-18 Thread Alex Robbins
Hmm, you posted the save method for your Event model, but not the definition. I think you haven't gotten any feed back because no one really knows what you are asking. Could you show the Event model, and then show what a finished save should look like? What should the data end up like? Alex On Ja

Efficient access through two manytomany layers

2010-01-17 Thread Alastair Campbell
Hi everyone, I have something that works, but I'm guessing it's *very* inefficient, I'm guessing that nested for-loops for two layers of many to many fields is bad, but how could I go about this better? The aim is for my admin users to fill in the sub-categories (classes), and for the system to w