[英]NoReverseMatch at / error on production server, but no issues in local
我在我的 django 應用程序中添加了一個 tos.html 頁面,它在本地運行良好,但是一旦我將其投入生產,它就會顯示這一點
NoReverseMatch at /
Reverse for 'tos' not found. 'tos' is not a valid view function or pattern name.
Request Method: GET
Request URL: http://www.flythecoop.io/
Django Version: 2.2.6
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'tos' not found. 'tos' is not a valid view function or pattern name.
Exception Location: /home/reviews/venv/lib/python3.8/site-packages/django/urls/resolvers.py in _reverse_with_prefix, line 673
Python Executable: /home/reviews/venv/bin/python3.8
Python Version: 3.8.0
Python Path:
['/home/reviews/venv/bin',
'/home/reviews/reviews',
'/home/reviews/venv/lib/python38.zip',
'/home/reviews/venv/lib/python3.8',
'/home/reviews/venv/lib/python3.8/lib-dynload',
'/usr/lib/python3.8',
'/home/reviews/venv/lib/python3.8/site-packages']
Server time: Tue, 11 Feb 2020 01:02:33 +0000
它在我的 base.html 文件中
63 </body>
64 <footer>
65 <br>
66 <p class="text-center">
67 <a class="btn btn-link btn-sm" href="{% url 'tos' %}" role="button">Terms of Service </a>
68 <a class="btn btn-link btn-sm" href="{% url 'about' %}" role="button">About </a>
69 <a class="btn btn-link btn-sm" href="{% url 'faq' %}" role="button">FAQ </a></p>
70 </footer>
71 </html>
這是我在頁面應用程序中的 urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.HomePageView.as_view(), name='home'),
path('tos/', views.TosPageView.as_view(), name='tos'),
path('about/', views.AboutPageView.as_view(), name='about'),
path('faq/', views.FaqPageView.as_view(), name='faq'),
]
這是我的 views.py
from django.shortcuts import render
from django.views.generic import TemplateView
# Create your views here.
class HomePageView(TemplateView):
template_name = 'home.html'
class TosPageView(TemplateView):
template_name = 'tos.html'
class AboutPageView(TemplateView):
template_name = 'about.html'
class FaqPageView(TemplateView):
template_name = 'faq.html'
這是項目級別的 urls.py
from django.contrib import admin
from django.urls import path, include
#from boards import views
urlpatterns = [
# This path for pages as static
path('', include('pages.urls')),
path('boards/', include('boards.urls')),
# path('boards/', include('boards.urls')),
path('admin/', admin.site.urls),
path('users/', include('users.urls')),
path('users/', include('django.contrib.auth.urls')),
]
我已經瀏覽了其他類似的問題,但大多數都是幾年前的,並且使用了不同的版本。 我想我一定遺漏了一些明顯的東西,但自從我添加一個頁面以來已經有一段時間了。
修復了它,我只需要為應用程序做sudo supervisorctl restart reviews
,我猜它開始為新頁面提供服務
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.