Django inverse class based on function name not working

According to django docs, viewname is either a function name or a url template name. But accessing a URL like this one back (MyView.as_view ()) turns into a NoReverseMatch exception. Is there a way to change the presentation of a class by function name?

+6
source share
1 answer

You can use named url patterns , or you can do something like the following (in views.py )

 my_function = MyView.as_view() 

now the opposite will work: reverse('myviews.my_function')

+6
source

All Articles