Reputation: 11068
Basically what I want to do is:
urlpatterns = patterns('',
url(r'^old/site/url.php?someshit=(?P<id>\d+)',
'website.views.redirect_php'),
)
But I always get a 404 ..
I've also tried to escape it like this
urlpatterns = patterns('',
url(r'^old/site/url\.php\?someshit\=(?P<id>\d+)',
'website.views.redirect_php'),
)
No luck.
Any ideas ?
Upvotes: 1
Views: 762
Reputation: 86924
What you're doing does not work because GET parameters are not included in the string being matched by URLconf. (See What the URLconf searches against.)
To achieve the desired behaviour, you'll need to extract the GET parameter from within the view and redirect according.
urlpatterns = patterns('',
url(r'^old/site/url\.php$',
view='website.views.redirect_php',
name='redirect_php'
),
)
and in your view:
def redirect_php(request):
id = request.GET.get("somesheet", None)
if id == None:
# handle case where "somesheet=?" was not provided
else:
# handle redirects based on id
Upvotes: 4
Reputation: 34593
Give this a try:
urlpatterns = patterns('',
url(r'^old/site/url\.php?someshit=(?P<id>\d+)$',
'website.views.redirect_php', name='redirect_php'),
)
Upvotes: 0