This is really nice. Both have their use cases, but I'm prefering the 
second when possible, because it's much more flexible and preserves 
database consistency.
With the same efford you can make the following work:

ProductEntry.objects.filter(lambda p: p.onpurchase_price * p.quantity 
== 5000.0)

Or if you don't like the lambda keyword, extend the Q object. Something 
like this:

ProductEntry.objects.filter(Q(onpurchase_price) * Q(quantity) == 5000.0)


Denormalisation is fine if you often do the same query. It's certainly 
easier to implement, but I wouldn't encourage it too much.



Le mercredi 17 juillet 2013 03:15:52 UTC+2, Alex_Gaynor a écrit :
>
> I'm going to suggest that a virtual field and a materialized field are 
> slightly different concepts, and porblaly have different internals. The 
> former requires some hooks in the ORM, the latter is really just some nice 
> wrapping around existing hooks.
>
> In any event there's probably some overal with the composite fields GSOC 
> for the virtual field, when we generalize fields to N>=1, I'm hoping that 
> makes generlaizing them to N=0 easier.
>
> Alex
>
>
> On Wed, Jul 17, 2013 at 11:12 AM, Jacob Kaplan-Moss 
> <ja...@jacobian.org<javascript:>
> > wrote:
>
>> On Tue, Jul 16, 2013 at 8:04 PM, Russell Keith-Magee <
>> rus...@keith-magee.com <javascript:>> wrote:
>>
>>> So - functionally, what you describe can be done. What's missing is 
>>> someone to polish the concepts into a patch for inclusion into Django's 
>>> repository. If this is something that interests you - get hacking! :-)
>>>
>>
>> I'll bet, in fact, that you could do *both* of these things in a *single* 
>> implementation. A hybrid property (to use your term) with a 
>> virtual/concrete flag sounds epic. Show me a good patch and I'll help get 
>> it merged!
>>
>> :)
>>
>> Jacob
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com <javascript:>.
>> To post to this group, send email to 
>> django-d...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-developers.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> "I disapprove of what you say, but I will defend to the death your right 
> to say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
> "The people's good is the highest law." -- Cicero
> GPG Key fingerprint: 125F 5C67 DFE9 4084
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to