In my Django application, I have a URL I would like to match which looks a little like this:
/mydjangoapp/?parameter1=hello¶meter2=world
The problem here is the ‘?’ character being a reserved regex character.
I have tried a number of ways to match this… This was my first attempt:
(r'^pbanalytics/log/\?parameter1=(?P<parameter1>[\w0-9-]+)¶meter2=(?P<parameter2>[\w0-9-]+), 'mydjangoapp.myFunction')
This was my second attempt:
(r'^pbanalytics/log/\\?parameter1=(?P<parameter1>[\w0-9-]+)¶meter2=(?P<parameter2>[\w0-9-]+), 'mydjangoapp.myFunction')
but still no luck!
Does anyone know how I might match a ‘?’ exactly in a Django URL?
Don’t. You shouldn’t match query string with URL Dispatcher.
You can access all values using
request.GETdictionary.urls
function