Hello,
Is it possible to use filter() to query objects based on comparisons
among attributes of the same object? For example, if my model Task has
two attributes start_year and end_year and I want to select all tasks
where start_year was somehow set later than end_year, I would try
something like

    q_backwards = models.Task.objects.filter(end_year__lt =
start_year)

but that gives a NameError ("global name start_year is not defined").
Is there any way to reference model object properties on the right
hand side of the filter argument?

All of the query examples in the docs compare the value of some
attribute to a constant. If the answer is that you can't compare one
attribute to another, is there a preferred strategy for this? A model
method, or custom SQL (hoping to avoid that 'cause I'd have to learn
SQL) or ....?

Many thanks for any help!
DG


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to