Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #567 -- Added HttpRequest.has_key() method. Thanks, wojtek3@bra…


git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8b67f5f829a998c860e107173584dcc4346d1225 1 parent 2d1303b
@adrianholovaty adrianholovaty authored
Showing with 15 additions and 0 deletions.
  1. +3 −0  django/utils/
  2. +12 −0 docs/request_response.txt
3  django/utils/
@@ -20,6 +20,9 @@ def __getitem__(self, key):
return d[key]
raise KeyError, "%s not found in either POST or GET" % key
+ def has_key(self, key):
+ return self.GET.has_key(key) or self.POST.has_key(key)
def get_full_path(self):
return ''
12 docs/request_response.txt
@@ -110,6 +110,18 @@ All attributes except ``session`` should be considered read-only.
+ Returns the GET/POST value for the given key, checking POST first, then
+ GET. Raises ``KeyError`` if the key doesn't exist.
+ This lets you use dictionary-accessing syntax on an ``HttpRequest``
+ instance. Example: ``request["foo"]`` would return ``True`` if either
+ ``request.POST`` or ``request.GET`` had a ``"foo"`` key.
+ Returns ``True`` or ``False``, designating whether ``request.GET`` or
+ ``request.POST`` has the given key.
Returns the ``path``, plus an appended query string, if applicable.
Please sign in to comment.
Something went wrong with that request. Please try again.