Hi,
I'm working with pagination of a large formset in my view function. For forms outside the range to be viewed, I'm currently doing this:
for form in results_formset:
place_to_test = int(form['placing'].value())
if place_to_test not in visible_range:
form.fields['race_number'].widget = HiddenInput()
visible_range is a list of places that should be viewed according to the pagination.
However, most of the formset is hidden. Simply using a HiddenInput() results in a large number of non-visible forms still being sent from the server. I have a scheme where I will condense the hidden information from the non-visible forms to save bandwidth. To do this within the current code structure requires me to be able to remove a non-visible form from the formset.
My code should become something like:
for form in results_formset:
place_to_test = int(form['placing'].value())
race_number = form['race_number'].value()
if place_to_test not in visible_range:
# need method to remove form from results_formset
pass
# condensing the information to save bandwidth
if place_to_test < range_min:
hidden_before.append("%s:%s" % (place_to_test, race_number))
elif place_to_test > range_max:
hidden_after.append("%s:%s" % (place_to_test, race_number))
I can't find how to remove the non-visible form from the formset - can anyone provide a pointer?
Best wishes,
Richard Brockie