Opened 12 years ago

Closed 11 years ago

#20323 closed Bug (needsinfo)

BaseFormsetSet.total_form_count seems to ignore absolute_maximum/MAX_NUM_FORM_COUNT once form is bound

Reported by: David Novakovic Owned by: nobody
Component: Forms Version: 1.5
Severity: Normal Keywords:
Cc: dpn@…, bmispelon@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This can be observed in the admin with an inline that has more than 1000 rows (1000 being the default absolute_maximum). It won't save because the range of forms generated is populated from the value of TOTAL_FORMS not MAX_NUM_FORM_COUNT.

The following code seems to fix it. I'm not 100% sure its the right approach though. Happy to jig up something with tests once we know the right approach!

def total_form_count(self):

"""Returns the total number of forms in this FormSet."""
if self.is_bound:

return self.management_form.cleaned_data[MAX_NUM_FORM_COUNT]

Change History (2)

comment:1 by David Novakovic, 12 years ago

Version: 1.41.5

comment:2 by Baptiste Mispelon, 11 years ago

Cc: bmispelon@… added
Resolution: needsinfo
Status: newclosed

Hi,

I don't really understand the problem you're describing (if you try to save more forms than allowed by absolute_max, then it's expected that you get an error, no?).
Would it be possible to provide a piece of code that demonstrates the issue?

Secondly, your proposed change doesn't seem right: MAX_NUM_FORM_COUNT is not the same as total_form_count.
In any case, the behavior of total_form_count changed with commit f9ab543720532400e8b0d490cdbe67ea09ae9c17 (this change addressed a potential security issue), so the approach needs to be different.

I'll mark this ticket as needsinfo. Please re-open it with some more details that can help us reproduce the issue.

Thanks.

Note: See TracTickets for help on using tickets.
Back to Top