I used this syntax

.extra(where=['%s >= %s - %s'], params=['criteria1_metric1',
'criteria1_metric2',  'criteria1_value'])

however I got error.


On Jul 24, 4:16 pm, David <ww...@yahoo.com> wrote:
> Here comes a new problem. I do not know which columns' values to use;
> all I know is that they are represented with variables. These
> variables are
>
> col_var_1, condition_operator, col_var_2, manipulation_operator,
> constant_value
>
> where:
> col_var_1:  col1, or col2, or col3, etc
> condition_operator: >, >=, <, =, etc
> col_var_2: col1, or col2, etc
> manipulation_operator: +, -, x, /
> constant_value: float value
>
> in the where clause, I have to use these variables. What's the
> syntax?
>
> any help? thanks so much.
>
> On Jul 24, 2:39 pm, David <ww...@yahoo.com> wrote:
>
>
>
> > Great. I go to pick up extra() to use.
>
> > Thanks Tim.
>
> > On Jul 24, 2:33 pm, Tim Chase <django.us...@tim.thechases.com> wrote:
>
> > > > Such a transformation is fine. I found that my Django has no F().
> > > > Checking the Django doc I saw that this new feature is "New in Django
> > > > Development version".
>
> > > > So I have to wait for the new version? Are there any other ways to
> > > > create such a filter?
> > > >>  col1_value >= col2_value * 2
>
> > > >> something like col1__gte=F('col2') * 2
>
> > > You can always fall back to the .extra() method[1]:
>
> > >    results = MyFoo.objects.extra(where=[
> > >      "col1_value >= col2_value * 2",
> > >      ])
>
> > > which is how it was done back in the day before ya'll young
> > > whippersnappers had such fancy shenanigans as F() objects...and
> > > to get data, we walked up hill, in the snow.  Both ways.  ;-)
>
> > > -tim
>
> > > [1]http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-sele...Hide
> > >  quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to