Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Kevin Christopher Henry, 11 years ago

Has patch: set
Owner: changed from nobody to Kevin Christopher Henry
Status: newassigned

comment:2 by Baptiste Mispelon, 11 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

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 Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In d34c8c338a843df2a540f19d15efc1ff12e3119c:

Fixed #21632 -- Docs: Removed example with callable as query parameter

Using callables as query parameters is undocumented and not working,
so this changes an example from the ForeignKey.limit_choices_to
documentation that uses it.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In dd7e2925dd63700a70f04a1e4c0df837acbdd55c:

[1.6.x] Fixed #21632 -- Docs: Removed example with callable as query parameter

Using callables as query parameters is undocumented and not working,
so this changes an example from the ForeignKey.limit_choices_to
documentation that uses it.

Backport of d34c8c338a from master

comment:5 by Tim Graham <timograham@…>, 11 years ago

In 6833773775fe135c38768418d31ec3f789d8f06f:

[1.5.x] Fixed #21632 -- Docs: Removed example with callable as query parameter

Using callables as query parameters is undocumented and not working,
so this changes an example from the ForeignKey.limit_choices_to
documentation that uses it.

Backport of d34c8c338a from master

comment:6 by Tim Graham, 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.

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