Search code examples
django-2.1

Redirect from one django app to another one (django 2.1)


I have an app ('admin') that acts as a login/authentication framework for the admin side of my django project. From there, I intend to send the user to the pages of the various apps under its control.

The urls.py of that app is as follows:

urlpatterns = [
    path('', views.login, name='login'),
    path('home/', views.home, name='home'),
    path('logout/', views.logout, name='logout'),
    path('voters/', include('voters.urls'), name='voters'),
]

but when I try to use a link from this a template in the 'admin' app to redirect to the other app's page, it gives me the following error:

Exception Type: NoReverseMatch at /admin/home/
Exception Value: Reverse for 'voters' not found. 'voters' is not a valid view function or pattern name

The HTML used to redirect is as follows -

<a href="{% url 'voters' %}" class="btn btn-primary"> Voters </a>

How can I redirect the user from this app to another app?


Solution

  • try : path('voters/', include('voters.urls')),

    and please share more parts of your code like models, views and full template