According to the django docs, viewname is either the function name or the url pattern name. But reversing an url like this 'reverse(MyView.as_view())' turns into a NoReverseMatch exception. Is there any way to reverse class based view by function name?
You can either used named url patterns or you can do something like the following (in your views.py
)
my_function = MyView.as_view()
now reverse will work: reverse('myviews.my_function')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With