Fixed #5535 -- Allow using an explicit foreign key in get() calls. Thanks, Michal Petrucha.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16473 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jannis Leidel 2011-06-28 10:16:18 +00:00
parent f54135fa4d
commit dbffffa7dc
3 changed files with 45 additions and 7 deletions

View file

@ -365,6 +365,16 @@ translates (roughly) into the following SQL::
.. _`Keyword Arguments`: http://docs.python.org/tutorial/controlflow.html#keyword-arguments
.. versionchanged:: 1.4
The field specified in a lookup has to be the name of a model field.
There's one exception though, in case of a
:class:`~django.db.models.fields.ForeignKey` you can specify the field
name suffixed with ``_id``. In this case, the value parameter is expected
to contain the raw value of the foreign model's primary key. For example::
>>> Entry.objects.filter(blog_id__exact=4)
If you pass an invalid keyword argument, a lookup function will raise
``TypeError``.