使用Django在/ pyCharm中的NoReverseMatch

时间:2022-01-09 19:17:58

On running my project with PyCharm as a django project on Windows, I am getting the above error. However, when I run this on my CentOS machine, all my pages are rendered fine. So, I was wondering if there is some change I need to make in order to make it compatible on Windows? Have you faced this issue before?

在使用PyCharm作为Windows上的django项目运行我的项目时,我收到上述错误。但是,当我在CentOS机器上运行时,我的所有页面都可以正常运行。所以,我想知道是否需要进行一些更改才能使其在Windows上兼容?你以前遇到过这个问题吗?

My code:

我的代码:

HTML file in templates:

模板中的HTML文件:

<a href={% url "my_view" variable1 variable2 %}><b> View Display </b></a>

app_name1/views.py

app_name1 / views.py

def my_view(request, variable1, variable2):
    #view function

app_name1/urls.py

app_name1 / urls.py

from django.conf.urls import patterns, include, url
from app_name1 import views

urlpatterns = patterns('app_name1.views',
url(r'^my_view/(?P<variable1>\d+)/(?P<variable2>\w+)/$', 'my_view', name='myview'),
)

1 个解决方案

#1


0  

You named your url myview (name='myview') but in your template you are requesting for my_view ({% url "my_view" variable1 variable2 %}).

您将您的网址命名为myview(name ='myview'),但在您的模板中,您要求my_view({%url“my_view”variable1 variable2%})。

Use {% url "myview" variable1 variable2 %} instead or change your url name to my_view.

请改用{%url“myview”variable1 variable2%}或将您的网址名称更改为my_view。

#1


0  

You named your url myview (name='myview') but in your template you are requesting for my_view ({% url "my_view" variable1 variable2 %}).

您将您的网址命名为myview(name ='myview'),但在您的模板中,您要求my_view({%url“my_view”variable1 variable2%})。

Use {% url "myview" variable1 variable2 %} instead or change your url name to my_view.

请改用{%url“myview”variable1 variable2%}或将您的网址名称更改为my_view。