0
このエラーはなぜですか? 引数 '()'およびキーワード引数 '{'要求 ':}'を使用して 'index'を逆にします。 0個のパターンが試行されました:[]
views.py
def index(request):
...
def book(request, cate):
...
def search(request):
if request.method == 'POST':
searchbooktitle = request.POST.get('search')
print(searchbooktitle)
try:
searchbook = Book.objects.filter(title__contains=searchbooktitle)
return redirect(book, request=request, cate=searchbook.pk)
except:
print(request)
return redirect(index, request=request)
return redirect(index, request=request)
urls.py
urlpatterns = [
url(r'^index/$', views.index, name='index'),
url(r'^book/(?P<cate>[a-zA-Z]+)/$', views.book, name='book'),
url(r'^chapter/(?P<pk>[0-9]+)/$', views.chapter, name='chapter'),
url(r'^content/(?P<bookpk>[0-9]+)/(?P<chapterpk>[0-9]+)/$', views.content, name='content'),
url(r'^search/$', views.search, name='search'),
]
Traceback Switch to copy-and-paste view
D:\Django1.8_env\lib\site-packages\django\core\handlers\base.py in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
D:\Djangodemo\bookmarks\account\views.py in search
return redirect('index', request=request) ...
▶ Local vars
この行では、リダイレクト(book、request = request、cate = searchbook.pk)、 を返すのですが、どうすればいいですか? –
return return '、cate = searchbook.pk) ' –