Django - Getting Post To Return A Dictionary Where The Values Are Lists
been stuck on this one for a while: We've got a view that has a number of dishes on it, like this: spaghetti tacos burger we want to have the user be able to enter two pieces of i
Solution 1:
Unfortunately, you're just going to have to use a different id for each grade and comment, then do some server side parsing to format your data nicely. Either that or you can do client side parsing and use a $.post to send JSON data to the server. I'd lean towards the second option, honestly, although you'll still have to do some server side validation/data sanitization.
If you go for the second option, you could do something like this:
<divid='spaghetti'><inputfield-type='grade' /><inputfield-type='comment' /></div><script>
$(document).ready(function() {
$('input[type=submit]').click(function() {
var data = {}
var grade = $('#spaghetti').children('input[field-type=grade]').first().val();
var comment = $('#spaghetti').children('input[field-type=comment]').first().val();
data['spaghetti'] = [grade, comment];
$.post('url', data);
}
}
Post a Comment for "Django - Getting Post To Return A Dictionary Where The Values Are Lists"