[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
This commit is contained in:
Kevin Christopher Henry 2013-12-18 00:40:25 -05:00 committed by Tim Graham
parent e4174da34a
commit 6833773775
1 changed files with 5 additions and 6 deletions

View File

@ -1023,14 +1023,13 @@ define the details of how the relation works.
.. attribute:: ForeignKey.limit_choices_to .. attribute:: ForeignKey.limit_choices_to
A dictionary of lookup arguments and values (see :doc:`/topics/db/queries`) A dictionary of lookup arguments and values (see :doc:`/topics/db/queries`)
that limit the available admin or ModelForm choices for this object. Use that limit the available admin or :class:`ModelForm <django.forms.ModelForm>`
this with functions from the Python ``datetime`` module to limit choices of choices for this object. For example::
objects by date. For example::
limit_choices_to = {'pub_date__lte': datetime.date.today} staff_member = models.ForeignKey(User, limit_choices_to={'is_staff': True})
only allows the choice of related objects with a ``pub_date`` before the causes the corresponding field on the ``ModelForm`` to list only ``Users``
current date to be chosen. that have ``is_staff=True``.
Instead of a dictionary this can also be a :class:`~django.db.models.Q` Instead of a dictionary this can also be a :class:`~django.db.models.Q`
object for more :ref:`complex queries <complex-lookups-with-q>`. However, object for more :ref:`complex queries <complex-lookups-with-q>`. However,