I'm having this weird problem.
When I did this:
from django.core.urlresolvers import reverse
reverse('account-reco-about-you')
# returns '/accounts/recommendations/about-you/'
But when I did this:
# Doesn't Work
recommendations = login_required(RedirectView.as_view(url=reverse('account-reco-about-you')))
# Work
recommendations = login_required(RedirectView.as_view(url='/accounts/recommendations/about-you'))
Error message I get if unrelated. It says my last view is not found, which is there. Any explanation? Meantime, i'll make do with the non-reverse style.
no need for reverse()
or reverse_lazy()
.
simply specify the pattern_name
parameter:
RedirectView.as_view(pattern_name='account-reco-about-you')
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