I'm using this django app: http://httpproxy.yvandermeer.net/
I'm using it to make requests to an external api, and it's working fine, however I'd like to modify the URL pattern and I'm not having much success.
In urls.py I have:
urlpatterns = patterns('',
(r'^api/(?P<url>.*)$', 'httpproxy.views.proxy'),
)
And I'm making an AJAX request like so:
$.ajax({
type: "GET",
url: "http://siteaddress.com/api/search/?query1={{ model.field1 }}&key=123456789",
....
As you can see, my API key is being displayed publicly on the front-end with my ajax call. I'd like to append it to the url pattern in urls.py, but it isn't working.
I've tried:
(r'^api/(?P<url>.*)$&key=123456789', 'httpproxy.views.proxy'),
(r'^api/(?P<url>.*)&key=123456789$', 'httpproxy.views.proxy'),
(r'^api/(?P<url>.*.&key=123456789)$', 'httpproxy.views.proxy'),
(r'^api/(?P<url>.*)$.&key=123456789', 'httpproxy.views.proxy'),
But none of those seem to work. Can I append the key to the end of this url pattern or is it not possible?
From Django docs:
The URLconf searches against the requested URL, as a normal Python string. This does not include GET or POST parameters, or the domain name.
You can't put GET parameters inside url regexp.