3

I want to achieve the same as this question : Redirect to named url pattern directly from urls.py in django?

but with a twist: my application has a namespace, and the selected answer no longer works right.

It works only if I include the namespace (app:) in the pattern_name parameter of RedirectView :

project/urls.py

urlpatterns = patterns(
    '',
    url(r'^', include('app.urls', namespace='app', app_name='app')
)

app/urls.py

urlpatterns = patterns(
    '',
    url(r'^newurl/$', my_view, name="my_view"),
    url(r'^oldurl/$', RedirectView.as_view(pattern_name='app:my_view')
)

But of course this is ugly and prevents the app from being reusable, which undermines the point of namespacing... So surely, there is a way to do this right, right?

Michael
  • 1,089
  • 1
  • 11
  • 28
Gohu
  • 2,050
  • 2
  • 18
  • 17

0 Answers0