Так вроде.
def project_document_add(request, id):
project = Project.objects.get(id=id)
if request.POST:
form = DocumentForm(request.POST)
if form.is_valid():
form.save()
return redirect('projectinfo', id)
org = ProjectCompany.objects.filter(project=project)
context = {
'form': DocumentForm(initial={'project': project, 'organization': org}),
'project': project
}
return render(request, 'documents/projectdocumentadd.html', context)
upd:
Я же QuerySet с ProjectCompany выбрал... Надо достать из него Organization...
Так может.
org = [company for company in ProjectCompany.objects.filter(project=project)]
context = {
'form': DocumentForm(initial={'project': project, 'organization': org}),
'project': project
}