I have a form which is editing a database entry and saving the changes back
to the database. after the changes are saved, I want to redirect to a
contract.html, where I want to populate the details of that entry. below is
the view: *def edit_res(request, pk=None):
if request.method == 'POST':
resident_form = EditItemForm(request.POST)
if resident_form.is_valid():
key = int(request.POST['id'])
resident = Resident.objects.get(pk=key)
resident_form = EditItemForm(request.POST, instance=resident)
resident_form.save()
#form = EditItemForm(request.POST, instance=key)
#resident = get_object_or_404(Resident, pk=key)
#form = EditItemForm(request.POST, instance=key)
#if form.is_valid():
#form.save()
#return HttpResponse('Saved form')
return redirect('Contract')
else:
item = Resident.objects.get(pk=pk)
form = EditItemForm(instance=item)
args = {}
args.update(csrf(request))
args['form'] = form
args['id'] = pk
return render_to_response('reg_form/edit.html', args)*
currently after the edited entry is saved, I redirected it to the
Contract.html page. I am trying to write a function, which can be called
above to return the data from the database: *def res(request,in_res_id):
data=Resident.objects.get(res_id=in_res_id) return
TemplateResponse(request,'Contract.html',{'data':data})*
My contract.html is like, where I want to populate the column value for
res_fname : *This skilled nursing facility Admission Agreement is entered
into between Located at and _{{data.res_fname}} (hereinafter “Resident”) *
Please advise. Thank you !
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/3d6a5d22-30f2-4081-9438-8bbeaf4fbad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.