Re: problems with get_or_create

2010-03-27 Thread Karen Tracey
On Sat, Mar 27, 2010 at 2:54 AM, Kenneth Gonsalves wrote: > thanks for the detailed reply - I now understand the issue. And yes, I did > read the documentation, but did not absorb it properly. A number of people have tripped over this sort of use of get_or_create; there is an open ticket (#12579

Re: problems with get_or_create

2010-03-26 Thread Kenneth Gonsalves
thanks for the detailed reply - I now understand the issue. And yes, I did read the documentation, but did not absorb it properly. Use of pyscopg1 is due to inertia. When I was first using django I had a lot of legacy code using psycopg1 and it was too much of a bother to migrate. That code is n

Re: problems with get_or_create

2010-03-26 Thread Karen Tracey
On Fri, Mar 26, 2010 at 1:49 AM, Kenneth Gonsalves wrote: > Here is what I mean - A simple model with two fields, 'name' is unique, > and 'num' is not null: > > >>> Tm.objects.get_or_create(name='me',num=1) > (, True) > >>> Tm.objects.get_or_create(name='me',num=2) > If you want get_or_create to

Re: problems with get_or_create

2010-03-25 Thread Kenneth Gonsalves
On Thursday 25 Mar 2010 9:17:12 pm Malcolm Tredinnick wrote: > I don't understand what you are saying here. If the instance exists (as > in, the filter parameters passed to get would return a single item), > that instance is returned and the default parameters are never > considered. So the values

Re: problems with get_or_create

2010-03-25 Thread Tom Evans
On Thu, Mar 25, 2010 at 4:23 PM, Malcolm Tredinnick wrote: > No, he's not, because Kenneth said that the instance exists. In your Actually, he described both situations where the instance exists, but with different values for the non-key attributes of the model, and where the instance doesn't exi

Re: problems with get_or_create

2010-03-25 Thread Malcolm Tredinnick
On Thu, 2010-03-25 at 15:58 +, Tom Evans wrote: [...] > > He is describing this situation: > > >>> User.objects.get(username='tevans...@googlemail.com') > > >>> User.objects.get_or_create(username='tevans...@googlemail.com') > (, False) > >>> User.objects.get(username='tevans...@googlemail.c

Re: problems with get_or_create

2010-03-25 Thread Tom Evans
On Thu, Mar 25, 2010 at 3:47 PM, Malcolm Tredinnick wrote: > On Thu, 2010-03-25 at 11:22 +0530, Kenneth Gonsalves wrote: >> hi, >> >> I have a model like this: >> >> name - unique >> slno - not null >> mode - not null >> >> If the instance does not exist and I give all three values to get_or_creat

Re: problems with get_or_create

2010-03-25 Thread Malcolm Tredinnick
On Thu, 2010-03-25 at 11:22 +0530, Kenneth Gonsalves wrote: > hi, > > I have a model like this: > > name - unique > slno - not null > mode - not null > > If the instance does not exist and I give all three values to get_or_create, > it works > > if the instance exists, and I give values for sl

Re: problems with get_or_create

2010-03-25 Thread Tom Evans
On Thu, Mar 25, 2010 at 10:29 AM, Daniel Roseman wrote: > > Actually the kwarg is 'defaults', not 'initial'. > > See > http://docs.djangoproject.com/en/1.1/ref/models/querysets/#get-or-create-kwargs > -- > DR. > Indeed :/ coffee++ Cheers Tom -- You received this message because you are subs

Re: problems with get_or_create

2010-03-25 Thread Daniel Roseman
On Mar 25, 9:32 am, Tom Evans wrote: > On Thu, Mar 25, 2010 at 5:52 AM, Kenneth Gonsalves wrote: > > hi, > > > I have a model like this: > > > name - unique > > slno - not null > > mode - not null > > > If the instance does not exist and I give all three values to get_or_create, > > it works > >

Re: problems with get_or_create

2010-03-25 Thread Tom Evans
On Thu, Mar 25, 2010 at 5:52 AM, Kenneth Gonsalves wrote: > hi, > > I have a model like this: > > name - unique > slno - not null > mode - not null > > If the instance does not exist and I give all three values to get_or_create, > it works > > if the instance exists, and I give values for slno and

problems with get_or_create

2010-03-24 Thread Kenneth Gonsalves
hi, I have a model like this: name - unique slno - not null mode - not null If the instance does not exist and I give all three values to get_or_create, it works if the instance exists, and I give values for slno and mode which are different from the existing ones - I get a programming error