Django Book 翻译
菜单>:
TOC
返回
原文:
.. table:: Table H-2. HttpRequest Methods +--------------------+--------------------------------------------------------+ |Method |Description | +====================+========================================================+ |``__getitem__(key)``|Returns the GET/POST value for the given key, checking | | |POST first, and then GET. Raises ``KeyError`` if the key| | |doesnt exist. | | | | | |This lets you use dictionary-accessing syntax on an | | |``HttpRequest`` instance. | | | | | |For example, ``request["foo"]`` is the same as checking | | |``request.POST["foo"]`` and then ``request.GET["foo"]`` | | |. | +--------------------+--------------------------------------------------------+ |``has_key()`` |Returns ``True`` or ``False`` , designating whether | | |``request.GET`` or ``request.POST`` has the given key. | +--------------------+--------------------------------------------------------+ |``get_full_path()`` |Returns the ``path`` , plus an appended query string, if| | |applicable. For example, | | |``"/music/bands/the_beatles/?print=true"`` | +--------------------+--------------------------------------------------------+ |``is_secure()`` |Returns ``True`` if the request is secure; that is, if | | |it was made with HTTPS. | +--------------------+--------------------------------------------------------+
翻译:
.. table:: 表 H-2. HttpRequest 的方法 +--------------------+--------------------------------------------------------+ |方法 |描述 | +====================+========================================================+ |``__getitem__(key)``|请求所给键的GET/POST值,先查找POST,然后是GET。 | | |若键不存在,则引发异常 ``KeyError`` 。 | | | | | |该方法使用户可以以访问字典的方式来访问一个 | | |``HttpRequest`` 实例。 | | | | | |例如, ``request["foo"]`` 和先检查 | | |``request.POST["foo"]`` 再检查 ``request.GET["foo"]`` 一| | |样。 | +--------------------+--------------------------------------------------------+ |``has_key()`` |返回 ``True`` 或 ``False`` , | | |标识 ``request.GET`` 或 ``request.POST`` 是否包含所给的 | | |键。 | +--------------------+--------------------------------------------------------+ |``get_full_path()`` |返回 ``path`` ,若请求字符串有效,则附加于其后。 | | |例如, ``"/music/bands/the_beatles/?print=true"`` 。 | +--------------------+--------------------------------------------------------+ |``is_secure()`` |如果请求是安全的,则返回 ``True`` 。 | | |也就是说,请求是以HTTPS的形式提交的。 | +--------------------+--------------------------------------------------------+
备注:
译者: