Re: merge data from multiple models

2012-08-01 Thread Melvyn Sopacua
On 31-7-2012 14:36, Joris wrote: > >> Hmm, I guess I'm missing the "real world use case" for this. Most >> importantly, I'm missing how this slow model relates to the fast model >> and what kind of query it is executing. I'm especially curious about the >> "as this statement is executed as an i

Re: merge data from multiple models

2012-07-31 Thread Melvyn Sopacua
On 31-7-2012 14:36, Joris wrote: > class SlowModel(models.Model): > rid_fastmodel = models.IntegerField(primary_key=True) > calcfield1 = models.TextField(blank=True) > calcfield2= models.TextField(blank=True) > > SQLstatement = "SELECT rid_fastmodel, calcfield1, calcfield2 from (SEL

Re: merge data from multiple models

2012-07-31 Thread Joris
> Hmm, I guess I'm missing the "real world use case" for this. Most > importantly, I'm missing how this slow model relates to the fast model > and what kind of query it is executing. I'm especially curious about the > "as this statement is executed as an instance of the model" bit. Ok, I'll t

Re: merge data from multiple models

2012-07-31 Thread Melvyn Sopacua
On 30-7-2012 19:50, joris benschop wrote: > > > Op maandag 30 juli 2012 16:06:38 UTC+2 schreef Joris het volgende: >> >> >> >> On Monday, July 30, 2012 3:52:31 PM UTC+2, Melvyn Sopacua wrote: >>> >>> >>> If this is not implemented as a OneToOneField, then do so. You can then >>> access the relat

Re: merge data from multiple models

2012-07-31 Thread Jirka Vejrazka
Hi there, > As templates cannot do lookups into a dictionary Templates can do lookups into a dictionary, see https://docs.djangoproject.com/en/1.4/topics/templates/#variables (check the "Behind the scenes" section). From what you've described, I'd try to prepare the necessary data in a v

Re: merge data from multiple models

2012-07-30 Thread joris benschop
Op maandag 30 juli 2012 16:06:38 UTC+2 schreef Joris het volgende: > > > > On Monday, July 30, 2012 3:52:31 PM UTC+2, Melvyn Sopacua wrote: >> >> >> If this is not implemented as a OneToOneField, then do so. You can then >> access the related object in the same way as the reverse of a ForeignKey

Re: merge data from multiple models

2012-07-30 Thread Joris
On Monday, July 30, 2012 3:52:31 PM UTC+2, Melvyn Sopacua wrote: > > > If this is not implemented as a OneToOneField, then do so. You can then > access the related object in the same way as the reverse of a ForeignKey > and use related_name to make this more intuitive. > Yes that works great

Re: merge data from multiple models

2012-07-30 Thread Melvyn Sopacua
On 30-7-2012 11:54, Joris wrote: > I'm trying to display data from a postgres backend into a HTML table. Most > of this data comes from a single table. Some columns however come from a > highly complex raw SQL query that is very CPU-expensive to run. The two > datasets cannot be combined into a

Re: merge data from multiple models

2012-07-30 Thread Joris
Thank you but that still makes me end up with two models (GROUPS and FINISH), although now both have the same records and are in the same order. When it comes to template rendering I still need a nester for loop yes? I suppose faking a foreign key relation in the FINISH model (which is the CPU

Re: merge data from multiple models

2012-07-30 Thread Kurtis Mullins
Try building this query set in your view and use the .filter() method. For example, relevant_data = ModelA.objects.filter(unique_field__in=ModelB.objects.all().values('unique_field')) https://docs.djangoproject.com/en/dev/ref/models/querysets/#in On Jul 30, 2012 7:27 AM, "Joris" wrote: > Dear

merge data from multiple models

2012-07-30 Thread Joris
Dear list, Apologies in advance if this is a FAQ. I did extensive searching through this list and the django docs but have not been able to find a solution. I'm trying to display data from a postgres backend into a HTML table. Most of this data comes from a single table. Some columns however co