~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to docs/ref/request-response.txt

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
298
298
          >>> q = q.copy() # to make it mutable
299
299
          >>> q.update({'a': '2'})
300
300
          >>> q.getlist('a')
301
 
          ['1', '2']
 
301
          [u'1', u'2']
302
302
          >>> q['a'] # returns the last
303
 
          ['2']
 
303
          [u'2']
304
304
 
305
305
.. method:: QueryDict.items()
306
306
 
309
309
 
310
310
           >>> q = QueryDict('a=1&a=2&a=3')
311
311
           >>> q.items()
312
 
           [('a', '3')]
 
312
           [(u'a', u'3')]
313
313
 
314
314
.. method:: QueryDict.iteritems()
315
315
 
329
329
 
330
330
           >>> q = QueryDict('a=1&a=2&a=3')
331
331
           >>> q.values()
332
 
           ['3']
 
332
           [u'3']
333
333
 
334
334
.. method:: QueryDict.itervalues()
335
335
 
369
369
 
370
370
         >>> q = QueryDict('a=1&a=2&a=3')
371
371
         >>> q.lists()
372
 
         [('a', ['1', '2', '3'])]
 
372
         [(u'a', [u'1', u'2', u'3'])]
373
373
 
374
374
.. method:: QueryDict.urlencode()
375
375
 
434
434
To set a header in your response, just treat it like a dictionary::
435
435
 
436
436
    >>> response = HttpResponse()
437
 
    >>> response['Pragma'] = 'no-cache'
 
437
    >>> response['Cache-Control'] = 'no-cache'
438
438
 
439
439
.. versionadded:: 1.1
440
440
 
462
462
    A normal Python string representing the content, encoded from a Unicode
463
463
    object if necessary.
464
464
 
 
465
.. attribute:: HttpResponse.status_code
 
466
 
 
467
    The `HTTP Status code`_ for the response.
 
468
 
465
469
Methods
466
470
-------
467
471
 
598
602
.. class:: HttpResponseServerError
599
603
 
600
604
    Acts just like :class:`HttpResponse` but uses a 500 status code.
601