diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-08-27 13:58:36 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-08-27 13:58:36 +0000 |
| commit | 35411fd7da0bfce6605d810c9844889f90cfb01b (patch) | |
| tree | d6bf9558375f1da4e3179a57d537b876a010d4e2 /docs | |
| parent | 188c6b3e9a99e7a5b53ebb57de0b8467c1131eee (diff) | |
[1.2.X] Fixed #14116 -- Added a flag to enable CSRF checks in the test client. Thanks to jon@licq.org for the suggestion.
Backport of r13640 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13642 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/csrf.txt | 7 | ||||
| -rw-r--r-- | docs/topics/testing.txt | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/docs/ref/contrib/csrf.txt b/docs/ref/contrib/csrf.txt index 979c221581..c32dd73986 100644 --- a/docs/ref/contrib/csrf.txt +++ b/docs/ref/contrib/csrf.txt @@ -398,6 +398,13 @@ set a flag on requests which relaxes the middleware and the ``csrf_protect`` decorator so that they no longer rejects requests. In every other respect (e.g. sending cookies etc.), they behave the same. +If, for some reason, you *want* the test client to perform CSRF +checks, you can create an instance of the test client that enforces +CSRF checks:: + + >>> from django.test import Client + >>> csrf_client = Client(enforce_csrf_checks=True) + Limitations =========== diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt index b101d574bb..c5f8f0040d 100644 --- a/docs/topics/testing.txt +++ b/docs/topics/testing.txt @@ -572,6 +572,19 @@ Note a few important things about how the test client works: This black magic (essentially a patching of Django's template system in memory) only happens during test running. + * By default, the test client will disable any CSRF checks + performed by your site. + + If, for some reason, you *want* the test client to perform CSRF + checks, you can create an instance of the test client that + enforces CSRF checks. To do this, pass in the + ``enforce_csrf_checks`` argument when you construct your + client:: + + >>> from django.test import Client + >>> csrf_client = Client(enforce_csrf_checks=True) + + .. _urllib: http://docs.python.org/library/urllib.html .. _urllib2: http://docs.python.org/library/urllib2.html |
