Populating form and having access to related objects
Hello
This is my view
@login_required
@transaction.commit_on_success
def companyedit(request, pk):
if request.method == 'POST':
a = Company.objects.get(pk=pk)
form = CompanyForm(request.POST, instance=a)
if form.is_valid():
form.save()
else:
company = get_object_or_404(Company, pk=pk)
form = CompanyForm(instance=company)
variables = RequestContext(request, {
'form': form,
'company': a
})
return render_to_response('contacts/update_company.html',
variables)
I would like to fetch the related Person objects that are related to
Company (ie. those who work for said company). I don't intend to use
this information in my form but intend to use it in the template.
Is this possible?
--
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