目前在Azure上设置一个Django Web应用程序,通过Git本地部署。我还没有编写任何代码,当我使用
启动开发服务器时TypeError at /
render() got an unexpected keyword argument 'context_instance'
并转到该网站的地址我收到以下错误:
"""
Definition of views.
"""
from django.shortcuts import render
from django.http import HttpRequest
from django.template import RequestContext
from datetime import datetime
def home(request):
"""Renders the home page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/index.html',
context_instance = RequestContext(request,
{
'title':'Home Page',
'year':datetime.now().year,
})
)
def contact(request):
"""Renders the contact page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/contact.html',
context_instance = RequestContext(request,
{
'title':'Contact',
'message':'Your contact page.',
'year':datetime.now().year,
})
)
def about(request):
"""Renders the about page."""
assert isinstance(request, HttpRequest)
return render(
request,
'app/about.html',
context_instance = RequestContext(request,
{
'title':'About',
'message':'Your application description page.',
'year':datetime.now().year,
})
)
它追溯到views.py,其中包含以下内容:
{{1}}
我不确定错误是什么,因为代码是在Azure中创建应用程序时生成的。据我所知,从文档中可以看出render()的参数是正确的。
答案 0 :(得分:4)
django.shortcuts.render
的第三个参数是If Cell.Value >= (-0.01) And Cell.Value <= 0.01 Then
stock = Sheets("results").Cells(Cell.row, 1)
Set find = Sheets("Signal").Columns(1).find(what:=stock, MatchCase:=True, Lookat:=xlWhole)
If find Is Nothing Then
MsgBox "add new data"
Else
MsgBox "Update data"
End If
End If
,而不是context
;您应该将context_instance
替换为context_instance=
(或者您可以将其作为位置参数传递)。除此之外,只需传递字典。
context=