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:
- http://grokbase.com/t/gg/django-users/149m2sb03t/slow-page-load-performance-with-a-large-number-of-formsets-over-25
- django formsets slow on many many relationships
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
Post a Comment