django redirect no reverse match error
Question: Here is my main project timecapture/urls.py content:

    
    
    from django.conf.urls import url,include
    from django.contrib import admin
    from django.core.urlresolvers import reverse_lazy
    from . import views
    
    
    urlpatterns = [ 
        url(r'^admin/', admin.site.urls),
        url(r'^$',views.index,name='index'),
        url(r'^login/$',views.auth_login,name='auth_login'),
        url(r'^logout/$',views.auth_logout,name='auth_logout'),
        url(r'^timesheet/',include('timesheet.urls'),name='timesheet')
    ]
    

And here is an app inside main project timesheet/urls.py:

    
    
    from django.conf.urls import url,include
    from django.contrib import admin
    from django.http import HttpResponse
    from . import views
    
    urlpatterns = [ 
        url(r'^$',views.index),
    ]
    

I am unable to redirect to 'timesheet' url. I am using the following command:

    
    
    return redirect('timesheet')
    

But this is working:

    
    
    return redirect('/timesheet/')
    

Exact error is `enter code here

    
    
    django.core.urlresolvers.NoReverseMatch: Reverse for 'timesheet' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
    

Btw I am using latest django 1.9.2 with python 3.4


Answer: You don't have a URL named "timesheet". You've got an include with that name,
but not the views.

Remove `name='timesheet'` from the include in the main urls.py, and add it
instead to the index url in timesheet/urls.py.

