[Django]-NoReverseMatch for Django form

5👍

Your get_success_url is wrong. Change it to the following:

def get_success_url(self):
    return reverse('profile-list')

reverse should be used in conjunction with the names that you give inside your urls.py patterns and not template names.

2👍

Your reverse call is incorrect. According to the docs:

reverse(viewname[, urlconf=None, args=None, kwargs=None,
current_app=None])

viewname is either the function name (either a
function reference, or the string version of the name, if you used
that form in urlpatterns) or the URL pattern name.

So, replace

reverse('profile_list.html')

with

reverse('profile-list')

profile-list is the URL pattern name, that you’ve defined in urls.py.

Hope that helps.

👤alecxe

Leave a comment