我用过1 * 1 tab11.html在我的应用中名为story / templates / story / tab11.html 如果我使用path('index / tab11.html /',views.tab11,name ='tab11'),则当
views.tab11仅包含返回render(request,tab11.html)的一行
请帮助我解决问题,以便我的url-index / tab11为我提供帮助
URL文件是:path('index / tab11 /',views.tab11,name ='tab11') 但是我在index.Reverse找不到index.Reverse为'tab11'的NoReverseMatch。 “ tab11”不是有效的视图函数或模式名称。
我的回溯是:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/index/
Django Version: 2.1.7
Python Version: 3.5.0
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'story',
'pages',
'users']
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']
Template error:
In template D:\Yashvi_Django\Imagualization_copy\story\templates\story\create_9.html, error at line 80
Reverse for 'tab11' not found. 'tab11' is not a valid view function or pattern name.
70 : <div class="container">
71 :
72 : </div>
73 : <h2 align="center">Select the Cell Layout for your Story/poem:</h2>
74 :
75 : <table align="center">
76 : <!-- Row 1-->
77 : <tr>
78 :
79 : <td >
80 : <div class="divclass" id="div1" ><h2 id="tab1"><a href= {% url 'tab11' %} >1*1</a></h2></div>
81 : </td>
82 : <td >
83 : <div class="divclass" id="div2"><h2 id="tab21"><a href="tab21.html">2*1</a></h2></div>
84 : </td>
85 : <td>
86 : <div class="divclass" id="div3"><h2 id="tab31"><a href="tab31.html">2*1</a></h2></div>
87 : </td>
88 : </tr>
89 : <!-- Row 2-->
90 : <tr>
Traceback:
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\core\handlers\base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\core\handlers\base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\Yashvi_Django\Imagualization_copy\story\views.py" in index
73. return render(request,'story/create_9.html')
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\shortcuts.py" in render
36. content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\loader.py" in render_to_string
62. return template.render(context, request)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\backends\django.py" in render
61. return self.template.render(context)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\base.py" in render
171. return self._render(context)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\base.py" in _render
163. return self.nodelist.render(context)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\template\defaulttags.py" in render
442. url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\urls\base.py" in reverse
90. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "C:\Users\DELL\.virtualenvs\Imagualization_copy-dFO-jx_p\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix
622. raise NoReverseMatch(msg)
Exception Type: NoReverseMatch at /index/
Exception Value: Reverse for 'tab11' not found. 'tab11' is not a valid view function or pattern name.