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 single model for performance reasons. > Both models do however have an identical unique field .
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. Example: from django.db import models class FastModel(models.Model) : name = models.CharField(max_length=32) class SlowModel(models.Model) : fast = models.OneToOneField(FastModel, related_name='slow', primary_key=True) description = models.TextField() @property def result(self) : return 1 + 1 >>> from one.models import FastModel, SlowModel >>> fast = FastModel.objects.get(pk=1) >>> slow = SlowModel(fast=fast, description='slow model 1') >>> slow.save() >>> fast.slow <SlowModel: SlowModel object> >>> fast.slow.description 'slow model 1' >>> fast.slow.result 2 -- Melvyn Sopacua -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.