Re: Populating form and having access to related objects
Javier
That's great and working, thank you.
I have modified my code and it appears to be working now. Does what I
have done now account for the GET scenario please? Thanks again!
def companyedit(request, pk):
if request.method == 'POST':
a = Company.objects.select_related().get(pk=pk)
form = CompanyForm(request.POST, instance=a)
if form.is_valid():
form.save()
else:
a = Company.objects.select_related().get(pk=pk)
form = CompanyForm(instance=a)
variables = RequestContext(request, {
'form': form,
'company': a
})
return render_to_response('contacts/update_company.html',
variables)
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home