0

I am having problems with an old project that was running on a deprecated django version. I updated django to 4.1.5 and made a few edits to the urls.py files that they were using python from django.conf.urls. I changed this to use re_path but now am running into an issue I have not been able to resolve.

The server starts up okay however when I try to access any of the pages, I get the following Error: Error:

NoReverseMatch at /control/ Reverse for 'control.views.set_notes' not found. 'control.views.set_notes' is not a valid view function or pattern name.

Looking at the Trace here is where it looks like the error is happening from url line below:

        $.ajax({
            url:  "{% url 'control.views.set_notes' %}",
            type: "POST",
            data: { 
                    'csrfmiddlewaretoken': '{{ csrf_token }}', 
                    'notes' : notes 
                  },
            error: function (error) {
                alert("error setting notes to " + notes);
            },
            success: function (response) {
            }

I have my root urls.py setup as follows:

from django.urls import include, re_path
    urlpatterns = (
        re_path(r'^control/', include('control.urls')),
        re_path(r'^profiles/', include('profiles.urls')),
        re_path(r'^roasts/', include('roasts.urls')),
)

My other control.urls.py setup is as follows:

from django.urls import re_path
import control.views


urlpatterns = (
    re_path(r'^$',               control.views.index),
    re_path(r'^get_state/$',     control.views.get_state),
    re_path(r'^cancel_profile/$',control.views.cancel_profile),
    re_path(r'^get_profile/$',   control.views.get_profile),
    re_path(r'^set_temp/$',      control.views.set_temp),
    re_path(r'^set_notes/$',     control.views.set_notes),
    re_path(r'^add_marker/$',    control.views.add_marker),
    re_path(r'^set_mode/$',      control.views.set_mode),
)

I am really stumped on this seems like I am missing something very obvious but have been starting at it all day.

redhawkbb
  • 1
  • 1
  • You are trying to pass the view name to the `{% url %}` template tag. You should be using the url name (i.e. you should add `name=` arguments to your `re_path` lines. – Selcuk Jan 23 '23 at 00:08

0 Answers0