I'm trying to make my a_detail
redirect to my a_detail_slug
url. I want to use the named url for this but I haven't succeeded yet, this is what I've tried:
url(r'^a/(?P<pk>\d+)/(?P<filler>[\w-]+)/$', AList.as_view(template_name="a.html"), name="a_detail_slug"),
url(r'^a/(?P<pk>\d+)/$', RedirectView.as_view(url=reverse_lazy("a_detail_slug"),), name="a_detail"),
This is meant to catch any link with a valid pk and redirect to that page with an appended filler.
a_detail_slug
requires 2 params (pk
and filler
) but you pass none of them. The easiest way will be extend RedirectView:
class ARedirect(RedirectView):
def get_redirect_url(self, pk):
filler = get_filler_somehow()
return reverse('a_detail_slug', args=(pk, filler))
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