#18434: Limit ModelFormSet queryset parameter
-------------------------------------+-------------------------------------
     Reporter:  sbaechler            |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |                  Version:  1.2
    Component:  Forms                |               Resolution:  needsinfo
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * status:  new => closed
 * needs_docs:   => 0
 * resolution:   => needsinfo
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 The intended way to use !ModelFormSets is:
 - 1 - on a GET request, instantiate a !ModelFormSet and render it in a
 template
 - 2 - on a POST request, instantiate the same !ModelFormSet with
 `request.POST`, process it and redirect

 If evaluating the queryset causes excessive load, things should blow up at
 step 1, not at step 2. The problem will be obvious: your page will contain
 a form for each row in the database. I don't understand exactly what
 you're doing, but it seems to me that your code for steps 1 and 2 wasn't
 in sync.

 I don't think it's worth attempting to magically hide such errors by
 restricting the queryset to POSTed objects.

 If that doesn't answer your question, could you provide a bit more
 information? In particular, explain why step 1 works but not step 2.
 Thanks!

 ----

 PS: I see that you've added some hardcoded filters to your view code. This
 isn't a maintainable solution because you just added tight coupling
 between your code and existing data in your production database. I don't
 know enough about your code base to suggest a better solution, but I
 recommend refactoring this.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18434#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to