OK - after playing around with this I am finding that it is rather difficult. Instead, I recommend that you only create the forms that you need in the first place in the view function. This requires a change in the structure of my code, so I'll have to make do for the time being with the larger than I would like file size.
On Thursday, May 19, 2016 at 8:18:17 AM UTC-7, Richard Brockie wrote:
-- On Thursday, May 19, 2016 at 8:18:17 AM UTC-7, Richard Brockie wrote:
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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53de4f70-6578-404b-b6c4-48a68dcf5900%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment