Python 我在DJango的RequestContext中获得AttributeError

Python 我在DJango的RequestContext中获得AttributeError,python,django,python-3.x,Python,Django,Python 3.x,如前所述,我希望在iframe问题中传递URL参数 我试着用下面的方法 回溯: Exception Type: AttributeError Exception Value: 'RequestContext' object has no attribute 'META' views.py from django.shortcuts import render from django.template import RequestContext def survey(request):

如前所述,我希望在iframe问题中传递URL参数

我试着用下面的方法

回溯:

Exception Type: AttributeError
Exception Value:    
'RequestContext' object has no attribute 'META'
views.py

from django.shortcuts import render
from django.template import RequestContext

def survey(request):
    return render(RequestContext(request),'wfhApp/survey.html')

我的html页面如下所示:

<!DOCTYPE html>
{% load django_typeform %}
{% load sekizai_tags %}
<html>
  <head>
    <title>Hello!</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/styles.css">

  </head>
  <body>

    <h1>Hi there!</h1>
    <div class="target-dom-node" style="width: 100%; height: 500px;"></div>
    <script src="https://embed.typeform.com/embed.js"></script>

    <script src="/survey/script.js"></script>
    {% typeforms_embed 'https://theother2thirds.typeform.com/to/hNZW30' 'New typeform' '{"hideHeaders": true, "hideFooter": true}' %}

    </body>
</html>

问题是您正在将
请求
包装在
RequestContext
对象中,这不适用于

render()
函数将为您构建
RequestContext
对象,因此它期望
request
和任何额外的上下文变量作为参数

相反,只需将请求直接传递给
render()
函数:

def调查(请求):
返回呈现(请求“wfhApp/survey.html”)

问题在于,您将
请求
包装在
请求上下文
对象中,这不适用于

render()
函数将为您构建
RequestContext
对象,因此它期望
request
和任何额外的上下文变量作为参数

相反,只需将请求直接传递给
render()
函数:

def调查(请求):
返回呈现(请求“wfhApp/survey.html”)

你能提供更多的回溯细节和你的
url.py
文件吗?@Tom,请检查我刚刚添加了
url.py
。你能提供更多的回溯细节和你的
url.py
文件吗?@Tom,请检查我刚刚添加了
url.py
。使用渲染功能后,我得到了<代码>异常类型:TemplateSyntaxError异常值:必须启用“sekizai.context\u processors.sekizai”模板上下文处理器或使用“sekizai.context.SekizaiContext”呈现模板。@MaqsudInamdar这是一个单独的问题。听起来您需要在
settings.py
中添加sekizai上下文处理器:但我已经添加了django sekizai。但在呈现模板时需要使用
django.template.RequestContext
。所以我不知道如何用这种方式渲染。在使用渲染函数之后,我得到了<代码>异常类型:TemplateSyntaxError异常值:必须启用“sekizai.context\u processors.sekizai”模板上下文处理器或使用“sekizai.context.SekizaiContext”呈现模板。@MaqsudInamdar这是一个单独的问题。听起来您需要在
settings.py
中添加sekizai上下文处理器:但我已经添加了django sekizai。但在呈现模板时需要使用
django.template.RequestContext
。因此,我不明白如何以这种方式渲染。
from django.conf.urls import url
from wfhApp import views

app_name = 'wfhApp'

urlpatterns = [
     url(r'^survey/$',views.survey, name='survey'),
]