Re: question about foreign key

2009-10-15 Thread tback
Hi jul, if there is a chance that the country doesn't exist you have to check that before. Have a look at get_or_create: http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create-kwargs Cheers, Till On Oct 15, 1:51 pm, jul wrote: > Hi, > > I've got the two models Country and Res

Re: question about foreign key

2009-10-15 Thread Daniel Roseman
On Oct 15, 1:46 pm, bruno desthuilliers wrote: > On 15 oct, 13:51, jul wrote: > > > Hi, > > > I've got the two models Country and Restaurant shown below. Is there a > > way to directly set a country by instanciating a restaurant with a > > Country instance? Something like: > > > r=Restaurant(nam

Re: question about foreign key

2009-10-15 Thread bruno desthuilliers
On 15 oct, 13:51, jul wrote: > Hi, > > I've got the two models Country and Restaurant shown below. Is there a > way to directly set a country by instanciating a restaurant with a > Country instance? Something like: > > r=Restaurant(name='whatever', country=Country(name='newcountry')) > r.save() >