ajax - Django + Jquery - serializing paginated arrays without using formsets -


i using django on back-end, , goal optimize code passes data front-end back-end via ajax calls.

in cases deal arrays restricted , small pieces of data, use html-forms, serialize them , pass on back-end, django processes post-request data via forms technology.

however, in case of large paginated data, since don't have forms , can't pass one-line code serializing form, have write tones of non-dry , fragile code passing data client django. django provides formsets scenario. problem had sad experience formsets seemed dramatically decrease speed of page load, , same opinion stated many folks on web:

on other hand, avoiding using formsets leads severe undryness of both cliend- , back-end code. more precise, let me provide skeleton of code snippet using now:

html:

{% obj in queryset %} <li>     <input class = 'class_a'>     <input class = 'class_b'>     <input...>     <button class = 'foo_press'/> </li> 

jquery:

$(document).on('click', '.foo_press', function(e){    e.preventdefault();    // below fragile code aimed @ getting data dom     var data = {'id': $(this).closest().find('.class_a).val(),                 ...                 ...                }           $.post('my_url', data, function(){..}); }  

i don't provide backend code. since interested in optimizing front-end now.

the question:

is there html/js code pattern enable data serialization , transmission backend without using django formsets?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -