Tuesday, July 31, 2012

Re: merge data from multiple models

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 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. Thanks!!
>>
>>
>>
> I'm sorry I spoke too soon. This does not work if the slow model is based
> on a raw SQL statement, as this statement is performed on an instance of
> the model. Referring to fastmodel.slow creates a new (unititialized)
> instance with no SQL backend and this crashes (relation does not exist).

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.

Using a view in PostgreSQL for that SQL statement and tying that to a
model seems like the obvious solution, but care should be taken with the
syncdb command (as in, the model tied to the view should not be 'synced').

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment