I am looking for a way to pass a string (an sql query) to Django view from JQuery. As such, I want my string to include any number of alphabetic characters, underlines and whitespaces ordered in arbitrary sequence. [\s_a-zA-Z0-9]+ seems to be the right regex for this, but I still end up failing to call my view. The problem lies in URLConf below:
url(r'^run_sql_query/(?P<sql_query_str>\[\s,=_a-zA-Z0-9]+)/$', get_sql_query_json_result)
The JQuery (which is 99% correct):
var sql_query_str = 'select ' +
'name, short_name, kpp, inn , okpo, phone_number_accounting,' +
'phone_number_ordering, description ' +
'from v_legal_entities WHERE is_vendor = 1';
$.ajax({
type:"GET",
url:"/run_sql_query/" + sql_query_str,
dataType : 'json',
cache: "false",
data:{},
success:function(obj)
{...// some code...
I have read this, but I still can't work it around.