#21632 closed Bug (fixed)
Docs: Unsupported example with a callable as a query parameter
Reported by: | Kevin Christopher Henry | Owned by: | Kevin Christopher Henry |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Using callables as query parameters is an undocumented feature (#11629) that doesn't seem to be working (#20241). As such, use of it was removed from the tutorial (#20249).
However, this usage still exists in an example accompanying the documentation for the limit_choices_to
argument to ForeignKey
. Let's use a different example.
Change History (6)
comment:1 by , 11 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 11 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Hi,
From my limited testing, using callable values in limit_choices_to
is only half-broken:
- It works when doing model validation (the callable is evaluated every time you call
model.full_clean()
) - Ir works in the admin if you let the admin generate a modelform for you (the callable is evaluated for every request).
- It's broken for modelforms (the callable is evaluated only when the
ModelForm
is declared, not when instanciated).
Consequently, I think it makes sense to remove it from the documentation, at least while we sort out #11629 and #20241.
However, your patch makes it seem like limit_choices_to
is only useful in the admin but that's not the case: it's a property that affects the generation of ModelForms
(both its rendering and its validation) and it's also used when doing model validation.
Thanks.
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:6 by , 11 years ago
For the record, bmispelon and I chatted about his comment above. He said he may have read the patch too quickly and missed that the note does mention ModelForm.
Patch here: https://github.com/django/django/pull/2087.