How can I find a named url in a view?

I want to fill out success_urldjango form forms using a named url:

class RegisterView(generic.edit.FormView):
    template_name = "cmmods/register.html"
    form_class = RegisterForm
    #success_url = reverse('complete-registration')
    success_url = "/cmmods/complete-registration"

When I type the URL explicitly, as mentioned above, it works.

When I try to do a reverse url search (currently commented above), I get:

Incoming urlconf 'cm_central.urls' does not contain any templates. If you see valid patterns in the file, then the problem is probably caused by circular import.

I think it’s clear that my urls.py is really valid (has templates in it), since the version of the code works without commenting.

How should I do it?

+4
source share
1 answer

, . reverse_lazy URL

:

success_url = reverse_lazy('complete-registration')

reverse_lazy

+10

All Articles