I am trying to pass parameters to Django view but I couldn’t decide what is the best way to do it.
I am making an AJAX call and my javascript code is
url = "/review/flag/code/"+ code +"/type/" + type + "/content/" + content + "/";
$.getJSON(url, somefunction);
The corresponding url for this call
(r'^rate/code/(?P<code>[-\w]+)/type/(?P<type>[-\w]+)/content/(?P<content>[-\w]+)/$', 'project.views.flag_review'),
And I can get the parameters in my view such that
def rate_review(request,code,type,content):
....
My question is because content comes from a textarea it may involve many escape chars and passing it like above causes problems due to regular expression.
Is there any way if I pass the parameters like http://www.xx.com/review/rate?code=1&type=2&content=sdfafdkaposdfkapskdf… ?
Thanks
If the
contentvariable is input through atextareainput field in a form, you should probably be using the HTTPPOSTmethod for submitting the data. You would get something like: