0

I have a custom Django app myapp with a urls.py like:

from django.conf.urls import patterns, url

urlpatterns = patterns('',
    url(r'^data/(?P<name>.+)$',
        'myapp.views.serve',
        name='myapp_getdata'),
)

I've confirmed that myapp is registered and is showing up in settings.INSTALLED_APPS. However, when I try to do:

reverse("myapp_getdata", args=('some/arbitrary/path_-_with_varying_characters.extension',))

I get a NoReverseMatch error. Why is this?

4
  • The urls.py is inside the app? or at the project level? Commented Feb 23, 2015 at 20:16
  • Post your project's urls.py plz Commented Feb 23, 2015 at 20:19
  • Are you sure your pattern matches the url? Commented Feb 23, 2015 at 20:21
  • did you include the app.urls into the site.urls (ROOT_URLCONF)? Commented Feb 23, 2015 at 20:36

1 Answer 1

1

By defining (?P<name>.+) in your URL, you're defining a kwarg called name. Try it with a kwarg;

reverse("myapp_getdata", kwargs={
    'name': 'some/arbitrary/path_-_with_varying_characters.extension'
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.