0
を通過するとき、私はURLにjQueryの配列を渡し、次のスクリプトを有する:ジャンゴ - INTの無効なリテラル()ベース10と:「」配列
jQuery(document).ready(function($) {
$("#continue").click(function() {
var selected = $("#meds").bootgrid("getSelectedRows");
var url = "{% url 'meds:prescription' 'test' %}";
url = url.replace('test', selected);
window.location = url;
});
});
及び次のビューを:
class PrescriptionView(generic.ListView):
template_name = 'meds/prescription.html'
context_object_name = 'meds'
model = Medicament
def get_queryset(self):
return Medicament.objects.filter(id__in=self.kwargs['selected'])
選択したアレイは[3, 4]
ようになりますし、URLがhttp://127.0.0.1:8000/prescription/3,4/
のようなルックスを渡され、私はエラーを取得しておいてください。
ValueError at /prescription/3,4/
invalid literal for int() with base 10: ','
私はちょうど私がリスト/アレイの項目にIDを比較することができるので、私はフィルタでid__in
を用いて渡された配列は、Pythonのリストとして扱われることを想定。