'formtools'を使用して保存する前にフォームをプレビューしようとしています。私はポストを訪問するとき、それは次のエラーを与える: リクエストメソッド:ここ/post/render_to_response()にエラーが発生しました。予期しないキーワード引数 'context_instance'が発生しました
Django Version: 1.10.1
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pagedown',
'bootstrapform',
'contact',
'crispy_forms',
'formtools',
'member']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ohid/test_venv/lib/python3.5/site-packages/formtools/preview.py" in __call__
34. return method(request)
File "/home/ohid/test_venv/lib/python3.5/site-packages/formtools/preview.py" in preview_get
58. context_instance=RequestContext(request))
Exception Type: TypeError at /post/
Exception Value: render_to_response() got an unexpected keyword argument 'context_instance'
http://127.0.0.1:8000/post/は私preview.pyです:: リクエストURLをGET
from .preview import PersonFormPreview
from .forms import MemberForm
from django import forms
url(r'^post/$', PersonFormPreview(MemberForm)),
:
ここ
from formtools.preview import FormPreview
from django.http import HttpResponseRedirect
from .models import Person
class PersonFormPreview(FormPreview):
form_template = 'member/person_form.html'
preview_template = 'member/person_review.html'
model = Person
def done(self, request, cleaned_data):
self.form.save()
# Do something with the cleaned_data, then redirect
# to a "success" page.
return HttpResponseRedirect('/form/success')
は私のURLです
このエラーを解決するにはどうすればよいですか?
質問タイトルを直接Googleにコピーしてみましたか... – Sayse