Django Redirect by Name - NoReverseMatch - Error with URLResolver

My django project name is 'exercises' and the app name is 'practice'. This basic application allows a user can navigate to different pages with a button click. The reference to each page uses the following href:

{% url 'practice:redirector' project.pk %}

Where practice:redirector points to my app (practice) url path named redirector. It is parameterized with the primary key of the page which I am trying to redirect to. See below app urls

This url points to practice views. There, I have a view set up for each page that corresponds to the name that the page will display. I also have a re director view that uses the pk passed in the url to pull the relevant page from my database and use the name as the argument in the redirect() shortcut:

practice views

I am expecting django to use the redirector view to redirect depending on the provided name. Using the debugger, I can see that the database is correctly queried and the correct name is passed to the redirect with each url: redirect to name

However, I get a NoReverseMatch error because django is using the project url file instead of my application url file to find the corresponding view.

Incorrect redirect

I need the resolver to look at 'practice.urls' instead of 'exercises.urls'. How can I do this? I have tried parameterizing urlconf=practice.urls within the redirect shortcut of the redirector view, but that does not work. Any and all feed back is very much appreciated! Thank you :)

Back to Top