I use JqGrid in Django template. It works fine until adding new row to the grid. I use for this "+" button on navigation panel. The problem is when I click "Submit" on "Add Record" dialog the HTTP 403 error appears. If I change editurl to "/ajax/stocks/add" (remove last slash) the HTTP 500 error appears.
Does someone know what the problem can be here ? In browser, query to http://127.0.0.1:8000/ajax/stocks/add/ (django dev server used) returns True as expected.
And I don't understand completely what ajax_stock_add_view function should do. Should it return success status or something else back?
Here is my django template:
{% block extrascript %}
<script type="text/javascript">
$(document).ready(function() {
jQuery("#stocks-grid").jqGrid(
{ url:'/ajax/stocks/', datatype: "json", colNames:['Name','Comment'],
colModel:[
{name:'name',index:'name', editable:true},
{name:'comment',index:'comment', editable:true}
],
editurl : "/ajax/stocks/add/", rowNum:10, pager: '#stocks-grid-pager', sortname: 'name', viewrecords: true});
jQuery("#stocks-grid").jqGrid('navGrid', '#stocks-grid-pager');
});
</script> {% endblock %}
{% block content %}
<table id="stocks-grid"></table>
<div id="stocks-grid-pager"></div> {% endblock %}
Here is urls.py:
...
(r'^ajax/stocks/$', ajax_stocks_view),
(r'^ajax/stocks/add/$', ajax_stocks_add_view),
...
and views.py
def ajax_stocks_view(request):
json = get_grid_json(Stock)
return HttpResponse(json, mimetype='application/json')
def ajax_stocks_add_view(request):
return HttpResponse(True)