I am using forms, to make the entries from the user. But when it comes to using foreign key in a table and then making entries to it, I am unable to do so. See my code:
models.py: class ClientJob(models.Model): """ :ClientJob: ClientJob Class is define all field reqiued to submit detail about new Job. """ job_no = models.AutoField(primary_key=True) receipt_no = models.CharField(max_length=15, editable=False) ....... class Amount(models.Model): id = models.AutoField(primary_key=True) job_no = models.ForeignKey(ClientJob) ......... and my views.py is def report_calculation(request): id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if request.method == 'POST': form =AmountForm(request.POST) if form.is_valid(): cd = form.cleaned_data job_no_id = client.job_no ....... form.save() return render_to_response('automation/job_ok.html', {'form': form, 'maxid':maxid}, context_instance=RequestContext(request)) else: form = AmountForm() return render_to_response('automation/job_add.html', {'form': form, 'maxid': maxid}, context_instance=RequestContext(request)) Am I wrong somewhere? How should I do this? Please help!! -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- 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.