Re: Newbie question - setting a model form foriegn key

2012-10-02 Thread Laxmikant Gurnalkar
Hi, I think yes, Otherwise database will raise an integrity error, like Foreign key violates the not null constraint. *--Laxmikant* *G.* On Tue, Oct 2, 2012 at 12:51 PM, Keir Lawson wrote: > Thanks for your reply :-) > > So there's no way to use a model form to proccess the quest and manual

Re: Newbie question - setting a model form foriegn key

2012-10-02 Thread Keir Lawson
Thanks for your reply :-) So there's no way to use a model form to proccess the quest and manually set just the FK of it? Keir On Tuesday, October 2, 2012 6:18:21 AM UTC+1, Laxmikant Gurnalkar wrote: > > Sorry, see again!! > > def payments_view(request, contact_id): > payment = Payment() >

Re: Newbie question - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
Sorry, see again!! def payments_view(request, contact_id): payment = Payment() contact = contact.objects.filter(id=contact_id) if contact: payment.contact = contact[0] payment.save() I dont think you are looking for this kind of thing : cheers On Tue, Oct 2, 2012

Re: Newbie question - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
def payments_view(request, contact_id): payment = Payment() payment.contact = contact[0] rctx = RequestContext(request,{ > 'contact': contact, 'payments': payments, 'form' : PaymentForm() > }) > return render_to_response('CRMSite/contact_payments.html',rctx) > On Tue,

Newbie question - setting a model form foriegn key

2012-10-01 Thread Keir Lawson
Sorry if this is a dumb question, just picking up Django. I've set up a payments form, to create payments associated with a contact (see payments model) however I'm having trouble figuring out how to save the payment with the relevant contact associated, as the contact isnt selected as part of