Thank you Alex .
It works!!!!
thank you very much.

Lima

On Mar 3, 12:59 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Mon, Mar 2, 2009 at 2:56 PM, limas <limasathyanan...@gmail.com> wrote:
>
> > thank you Alex for your valuable reply.
> > but i am still not able to find out the solution.
> > i tried this:
> > dataobj=DataValue.objects.filter(Q(file=file.id)|Q(mnem=1)|Q(mnem=2))
> > but it is not working fine.  it is returning every thing.
>
> > can you suggest some thing more. It will realy help a newbie like me.
> > thanks .....
>
> > Lima
>
> > On Mar 3, 12:40 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > > On Mon, Mar 2, 2009 at 2:36 PM, limas <limasathyanan...@gmail.com>
> > wrote:
>
> > > > Hello.....
>
> > > > my project deals with mnemonic-data pairs.
> > > > so I have model like this:
>
> > > > class DataValue(models.Model):
> > > >        file=models.ForeignKey(File)
> > > >        row=models.IntegerField()
> > > >        mnem=models.IntegerField()
> > > >        value=models.CharField(max_length=2000)
>
> > > > class Curve(models.Model):
> > > >        file=models.ForeignKey(File)
> > > >        mnem=models.CharField(max_length=100)
>
> > > > mnem field of DataValue contains the curve id,  but it not set as the
> > > > foreign key.
> > > > so for each set of mnemonic data pairs for same file id i am trying to
> > > > maintain row numbers.
>
> > > > where i am failing is that ......
> > > > i want to get a particular two mnemonic pairs.
> > > > my query is like this:
>
> > > >  dataobj=DataValue.objects.filter(file=file.id).filter(mnem=1,mnem=2)
> > > > where 1 and 2 are the curve ids for a particular condition.
>
> > > > but i am getting only records corresponding to mnem=2.
>
> > > > any valuable suggestions ? please help me......
> > > > i think it might be some minor misunderstatnding.
>
> > > > thanks in advanse
> > > > Lima
>
> > > This is a bit about how Python works, when you do filter(mnem=1, mnem=2)
> > > since the filter method takes **kwargs that translates that into a
> > > dictionary {'mnem': 1, 'mnem': 2}, but wait, python dics don't have
> > > duplicate keys, the last key wins, so it just because {'mnem': 2}.  To
> > fix
> > > this you want to seperate it into 2 filter calls
> > > filter(mnem=1).filter(mnem=2).  But that still probably doesn't do what
> > you
> > > want, since you can't have a field which has 2 values at once, therefore
> > I'm
> > > guessing you want to OR them together,
> >http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-looku...
> > > probably what you want.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right
> > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
> You aren't being very clear on what you're trying to do, but my inclination
> is that you want something like:
> DataValue.objects.filter(file=file.id).filter(Q(mnem=1)|Q(mnem=2))
>
> Which asks for all DataValue objects where (file=file.id) AND (mnem=1 OR
> mnem=2)
>
> Alex
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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