However, this usage still exists in an
[https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to
example] accompanying the documentation for the `limit_choices_to`
argument to `ForeignKey`. Let's use a different example.
--
Ticket URL: <https://code.djangoproject.com/ticket/21632>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* owner: nobody => marfire
* needs_docs: => 0
* has_patch: 0 => 1
Comment:
Patch here: https://github.com/django/django/pull/2087.
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:1>
* needs_better_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:2>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d34c8c338a843df2a540f19d15efc1ff12e3119c"]:
{{{
#!CommitTicketReference repository=""
revision="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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:3>
Comment (by Tim Graham <timograham@…>):
In [changeset:"dd7e2925dd63700a70f04a1e4c0df837acbdd55c"]:
{{{
#!CommitTicketReference repository=""
revision="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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"6833773775fe135c38768418d31ec3f789d8f06f"]:
{{{
#!CommitTicketReference repository=""
revision="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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:5>
Comment (by timo):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/21632#comment:6>