私は、ウェブサイトの管理領域にアクセスすることができますが、私はホームページに得るカントや他のフロントエンドpages..followingエラーがポップアップ表示...ここジャンゴとPythonの例外TypeError
> TypeError at/render_to_response() got an unexpected keyword argument
> 'context_instance' Request Method: GET Request
> URL: http://127.0.0.1:8000/ Django Version: 1.10.6 Exception
> Type: TypeError Exception Value: render_to_response() got an
> unexpected keyword argument 'context_instance' Exception
> Location: C:\Users\DEEP\Desktop\Bus_reservation\src\bus\views.py in
> index, line 10 Python Executable: C:\Python34\python.exe Python
> Version: 3.4.4 Python Path:
> ['C:\\Users\\DEEP\\Desktop\\Bus_reservation\\src',
> 'C:\\WINDOWS\\SYSTEM32\\python34.zip', 'C:\\Python34\\DLLs',
> 'C:\\Python34\\lib', 'C:\\Python34',
> 'C:\\Python34\\lib\\site-packages']
がTRACEBACK
> Environment:
>
>
> Request Method: GET Request URL: http://127.0.0.1:8000/
>
> Django Version: 1.10.6 Python Version: 3.4.4 Installed Applications:
> ['bus.apps.BusConfig', 'bookTicket.apps.BookticketConfig',
> 'account.apps.AccountConfig', 'django.contrib.admin',
> 'django.contrib.auth', 'django.contrib.contenttypes',
> 'django.contrib.sessions', 'django.contrib.messages',
> 'django.contrib.staticfiles'] Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback:
>
> File "C:\Python34\lib\site-packages\django\core\handlers\exception.py"
> in inner
> 42. response = get_response(request)
>
> File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in
> _legacy_get_response
> 249. response = self._get_response(request)
>
> File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in
> _get_response
> 187. response = self.process_exception_by_middleware(e, request)
>
> File "C:\Python34\lib\site-packages\django\core\handlers\base.py" in
> _get_response
> 185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
> File "C:\Users\DEEP\Desktop\Bus_reservation\src\bus\views.py" in index
> 10. return render_to_response(template_name,locals(),context_instance=RequestContext(request))
>
> Exception Type: TypeError at/Exception Value: render_to_response()
> got an unexpected keyword argument 'context_instance'
ですここで
は、私のファイルviews.pyである - BUS
> from django.shortcuts import render_to_response from django.http
> import HttpResponse from django.template import RequestContext from
> .models import BusInfo,BusDropArea,BusPickArea
>
> import json
>
> def index (request, template_name ='bus_resrv_system.html'):
> page_title = 'Bus'
> return render_to_response(template_name,locals(),context_instance=RequestContext(request))
>
> def search_bus(request,template_name ='bus/search_bus.html'):
> page_title = 'Book a ticket'
>
> if request.method == 'POST':
> post_data = request.POST.copy()
> area_from_id = post_data.get('area_from_id')
> area_to_id = post_data.get('area_to_id')
> bus_info_list= BusInfo.objects.filter(arriving_from_id=area_from_id,depature_at_id=area_to_id)
> return render_to_response(template_name, locals(), context_instance=RequestContext(request))
>
>
> def autocomplete_pick(request):
> if request.is_ajax():
> q = request.GET.get('term', '')
> drugs = BusPickArea.objects.filter(area_name__icontains = q)[:20]
> results = []
> for drug in drugs:
> drug_json = {}
> drug_json['id'] = drug.id
> drug_json['label'] = drug.area_name
> drug_json['value'] = drug.area_name
> results.append(drug_json)
> data = json.dumps(results)
> else:
> data = 'fail'
> mimetype = 'application/json'
> return HttpResponse(data, mimetype)
>
> def autocomplete_drop(request):
> if request.is_ajax():
> q = request.GET.get('term', '')
> drugs = BusDropArea.objects.filter(area_name__icontains = q)[:20]
> results = []
> for drug in drugs:
> drug_json = {}
> drug_json['id'] = drug.id
> drug_json['label'] = drug.area_name
> drug_json['value'] = drug.area_name
> results.append(drug_json)
> data = json.dumps(results)
> else:
> data = 'fail'
> mimetype = 'application/json'
> return HttpResponse(data, mimetype)
エラーを解決することに加えて、私はまた、レンダリングを変更しています_to_responseメソッドは古いDjangoライブラリの問題ごとにレンダリングしますが、未定義のレンダリングのためにNameErrorがポップアップします!!
予想外のキーワード引数 'context \ _instance'が[Djangoエラー:render \ _to \ _response()に重複している可能性があります](http://stackoverflow.com/questions/38739422/django-error-render-to-response -got-an-unexpected-keyword-argument-context-i) – Tim