Having trouble using reverse()

476 views Asked by At

It feels like this is a simple problem but I am obviously missing something.

url = reverse('specific', args=(var.pk,))
print(url)

The error message i get is:

Reverse for 'specific' with arguments '(1,)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Here are my urls:

For myapp level

    urlpatterns = [
    ... some stuff ...
    url(r'^specific/(?P<var_id>[0-9]+)/$', views.specific, name='specific'),
]

And these are for the project level

urlpatterns = [
url(r'^$', 'myapp.views.index', name='index'),
url(r'^admin/', include(admin.site.urls)),
url(r'^myapp/', include('myapp.urls', namespace="TestData")),

]

Feels like I'm missing something simple but I am new at this

1

There are 1 answers

0
pythad On BEST ANSWER

You are using namespace in you project urls, namespace="TestData", so you also have to provide it in your urls:

url = reverse('TestData:specific', args=[str(var.pk)])