Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added to the documentation the django.test.Client.defaults definition. #115

Closed
wants to merge 3 commits into from

1 participant

Raúl Cumplido
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  AUTHORS
@@ -136,9 +136,10 @@ answer newbie questions, and generally made Django that much better:
136 136
     Robert Coup
137 137
     Pete Crosier <pete.crosier@gmail.com>
138 138
     Matt Croydon <http://www.postneo.com/>
  139
+    Jure Cuhalev <gandalf@owca.info>
139 140
     Leah Culver <leah.culver@gmail.com>
  141
+    Raúl Cumplido <raulcumplido@gmail.com>    
140 142
     flavio.curella@gmail.com
141  
-    Jure Cuhalev <gandalf@owca.info>
142 143
     John D'Agostino <john.dagostino@gmail.com>
143 144
     dackze+django@gmail.com
144 145
     Jim Dalton <jim.dalton@gmail.com>
26  docs/topics/testing.txt
@@ -664,11 +664,33 @@ Note a few important things about how the test client works:
664 664
 Making requests
665 665
 ~~~~~~~~~~~~~~~
666 666
 
667  
-Use the ``django.test.client.Client`` class to make requests. It requires no
668  
-arguments at time of construction:
  667
+Use the ``django.test.client.Client`` class to make requests.
669 668
 
670 669
 .. class:: Client()
671 670
 
  671
+    It requires no arguments at time of construction but you can provide some
  672
+    default values:
  673
+
  674
+    .. method:: Client.__init__(enforce_csrf_checks=False, **defaults)
  675
+
  676
+        Creates an instance of the test client.
  677
+
  678
+        The ``defaults`` keywords argument parameter can be used to specify 
  679
+        some default headers to be sent in the request. For example::
  680
+
  681
+            >>> c = Client(HTTP_USER_AGENT='Mozilla/5.0')
  682
+
  683
+        ...will send the HTTP header ``HTTP_USER_AGENT`` on further requests.
  684
+
  685
+        The values from the ``extra`` keywords argument on the 
  686
+        :meth:`django.test.client.Client.get()`, 
  687
+        :meth:`django.test.client.Client.post()`, 
  688
+        :meth:`django.test.client.Client.delete()`
  689
+        , etc. have precedence than those defaults provided.
  690
+
  691
+        By default the test client  will disable any CSRF checks performed by
  692
+        your site due to the default ``enforce_csrf_checks`` value.
  693
+
672 694
     Once you have a ``Client`` instance, you can call any of the following
673 695
     methods:
674 696
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.