Re: Null constraint violations when saving objects with ForeignKey relationships

2013-06-14 Thread kvlulla
Hi Lukasz.. Thanks it was helpful..i was looking for something like this. -Karan On Sunday, December 27, 2009 12:50:05 PM UTC-8, Łukasz Balcerzak wrote: > > Hi there, > > Well, just try to make sure you are passing already saved instance (having > primary key set) > into related model which has

Re: Null constraint violations when saving objects with ForeignKey relationships

2009-12-27 Thread Łukasz Balcerzak
Hi there, Well, just try to make sure you are passing already saved instance (having primary key set) into related model which has foreign key to the first one. Your approach: > from test.models import A,B > instA = A() > instB = B(a=instA) > > Now I'm done with my parsing and am happy to save

Re: Null constraint violations when saving objects with ForeignKey relationships

2009-12-27 Thread Gunther Mayer
Ok, not sure why I'm not getting replies, perhaps my problem is too complex or I'm being too silly with my approach. Either way, I found a work around by writing a little function to prepare my objects for saving which ensures that django finds the fkey id's when I issue my save(): def prepare_

Null constraint violations when saving objects with ForeignKey relationships

2009-12-26 Thread gmayer
Hi guys, I'm new to Django but otherwise quite a seasoned python and sql programmer. I'm baffled by django's foreign key id behaviour and as a result stuck in my current coding project. Let me start immediately with an example of what I'm trying to do. Assume two very simple models: class A(model