简体   繁体   中英

URL not reversing in template Django

Right now I'm having issues getting the url tag to reverse back to my urls. I'm getting the NoReverseMatch. Specifically its

Error

django.urls.exceptions.NoReverseMatch: Reverse for 'documents' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

I've tried narrowing it down using other url names to reverse, but they also don't work. I'm guessing its something to do with calling the url. Any help will be awesome. If anything else is needed just let me know.

urls.py

"""urls for vivid"""
from django.conf.urls import url
from . import views

app_name = 'website'
urlpatterns = [
    url(r'^$',
        views.login_view,
        name='login'),
    url(r'^dashboard/$',
        views.dashboard_view,
        name='dashboard'),
    url(r'^home/$',
        views.home_view,
        name='home'),
    url(r'^addshow/$',
        views.show_add_view,
        name='addshow'),
    url(r'^regis/$',
        views.regis_view,
        name='regis'),
    url(r'^show/(?P<show_id>[0-9]+)/$',
        views.detail_show_view,
        name='detailshow'),
    url(r'^show/(?P<show_id>[0-9]+)/documents$',
        views.documents_view,
        name='documents'),
    url(r'^addcardcomp/$',
        views.add_card_comp,
        name='addcomp'),
    url(r'^homecardcomp/$',
        views.home_card_comp,
        name='homecomp'),

]

templates

<a href="{% url 'documents' show_id=showDocumentID %}" 

Try to use:

<a href="{% url 'website:documents' show_id=showDocumentID %}" 

Because: <"app_name">: <"url_name"> is better (don't conflict with other app)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM