0

My root url conf is

urlpatterns = patterns(
    '',
    url(r'^config-menu/', include('configuration.urls')),
    url(r'^', include('web.urls')),
)

and configuration.urls looks like this

urlpatterns = patterns(
    url(r'^$', ConfigHomeView.as_view(),
        name='config_home'),

    url(r'^address_labels/create$', AddressLabelCreateView.as_view(),
        name='address_label_create'),
)

Now observe this:

>>> reverse('address_label_create')
'/config-menu/address_labels/create'
>>> reverse('config_home')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ruben/v3env/lib/python3.4/site-packages/django/core/urlresolvers.py", line 551, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/home/ruben/v3env/lib/python3.4/site-packages/django/core/urlresolvers.py", line 468, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
django.core.urlresolvers.NoReverseMatch: Reverse for 'config_home' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

How come I can resolve one, but not the other?

Eldamir
  • 9,888
  • 6
  • 52
  • 73

3 Answers3

1

The first argument to patterns is supposed to be the prefix, in this case probably ''.

Wander Nauta
  • 18,832
  • 1
  • 45
  • 62
  • That did it. I'd even thought about that and thought I'd checked for it. Meh... To long day i suppose. Thanks ;) – Eldamir Aug 19 '15 at 10:55
1

Include '' after patterns

Like this:

urlpatterns = patterns('',
    url(r'^$', ConfigHomeView.as_view(),
        name='config_home'),

    url(r'^address_labels/create$', AddressLabelCreateView.as_view(),
        name='address_label_create'),
)

This should resolve your issue.

Arpit Goyal
  • 2,212
  • 11
  • 31
0

Add '' after patterns

urlpatterns = patterns('',
    url(r'^$', ConfigHomeView.as_view(),
        name='config_home'),
)

Please see the patterns() docs.

chandu
  • 1,053
  • 9
  • 18