2
當前在Azure上設置了一個Django Web應用程序,通過Git在本地部署。我還沒有實際編寫任何代碼然而,當我使用/render()的Django TypeError獲得了一個意外的關鍵字參數'context_instance'
python3 manage.py runserver
啓動開發服務器,並轉到網站的地址,我收到以下錯誤:
TypeError at/
render() got an unexpected keyword argument 'context_instance'
它追蹤到的意見。 py,它有以下內容:
"""
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,
})
)
我不確定錯誤是什麼,因爲代碼是在Azure中創建應用程序時生成的。據我可以從文檔中知道render()的參數是正確的。