Django

Code

Ticket #3534 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

newforms ModelChoiceField should not cache choices

Reported by: adrian Assigned to: adrian
Milestone: Component: Forms
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

ModelChoiceField and ModelMultipleChoiceField cache the output of their queryset the first time self.choices is accessed. This is bad for long-running processes, such as mod_python, because the cache gets stale. Plus, it's bad saving all of those choices in memory. The attached unit tests illustrate the problem.

Attachments

model_choice_field_cache_tests.patch (1.1 kB) - added by adrian on 02/19/07 23:18:28.
Unit tests

Change History

02/19/07 23:17:34 changed by adrian

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

02/19/07 23:18:28 changed by adrian

  • attachment model_choice_field_cache_tests.patch added.

Unit tests

02/20/07 23:14:29 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [4552]) Fixed #3534 -- newforms ModelChoiceField? and ModelMultipleChoiceField? no longer cache choices. Instead, they calculate choices via a fresh database query each time the widget is rendered and clean() is called


Add/Change #3534 (newforms ModelChoiceField should not cache choices)




Change Properties
Action