[Answer]-Django urls.py Regex Not Working Like I Expected

1đź‘Ť

âś…

My guess is you’re including the “chart” URI component already in the project-level (IE, root) urlconf, so including it again the app’s urlconf is throwing off the resolver. Basically try removing the “chart/” from the chart url, like so:

from django.conf.urls import patterns,url
from musichart import views

urlpatterns = patterns('',
    url(r'^$', views.index, name="index"),
    url(r'^(?P<year>\d+)$',views.chart,name="chart"),
)

And in addition, double check that you don’t have a trailing space after “chart” when including the app-level urlconf from the root urlconf.

👤technivore

Leave a comment