Excellent thank you.
So the solution is:
from django.db.models import F
X.objects.filter(id = F('new_id'))
Thanks for the help guys.
On 8 Gru, 19:38, Boris Schäling <[email protected]> wrote:
> > -----Original Message-----
> > From: [email protected] [mailto:django-
> > [email protected]] On Behalf Of pbzRPA
> > Sent: Tuesday, December 08, 2009 7:19 PM
> > To: Django users
> > Subject: Filtering queryset using two fields in one model
>
> > Hi,
>
> > I am not sure if this is a really stupid question but how can you
> > filter a model by comparing two of it's own fields?
>
> > for example:
>
> > class X(models.Model):
> > id = models.IntegerField()
> > new_id = models.IntegerField()
>
> > now I want to say X.objects.filter(id = new_id)
>
> Seehttp://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-r...
> e-fields-on-the-model
>
> What is missing though is a feature to put a literal value on the left hand
> side - for example:
>
> X.objects.filter(1 = id)
>
> (Here for the equality operator it doesn't matter of course.)
>
> Boris
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
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.