上下文未从views.py到达python django中的页面
我有一个Django应用程序,正在尝试将一些context views.py发送到特定页面:上下文未从views.py到达python django中的页面,python,django,Python,Django,我有一个Django应用程序,正在尝试将一些context views.py发送到特定页面: status = True context = {'status': status } return render(request, "sample/Newsample.html",{"form":ProfileForm() } ,context) 但是上下文没有到达Newsample.html。代码的语法有错误吗?ProfileForm()是我的forms.py中的某个方法,我认为它与上下文
status = True
context = {'status': status }
return render(request, "sample/Newsample.html",{"form":ProfileForm() } ,context)
但是上下文没有到达Newsample.html。代码的语法有错误吗?ProfileForm()是我的forms.py中的某个方法,我认为它与上下文无关
有什么帮助吗
status = True
context = {'status': status }
return render(request, "sample/Newsample.html",{"form":ProfileForm() } ,context)
应该是
status = True
context = {'status': status , 'form': ProfileForm()}
return render(request, "sample/Newsample.html", context)
render传递给模板的上下文是第三个参数,所以您需要根据需要更新代码
status = True
context = {'status': status ,
"form":ProfileForm()
}
return render(request, "sample/Newsample.html", context)