On Thu, Dec 10, 2009 at 2:06 AM, Phlip <phlip2...@gmail.com> wrote:
> On Aug 14 2008, 5:39 am, "Hajo Smulders" <hajosmuld...@gmail.com>
> wrote:
>
>> I need to set the HTTP_REFERER in the request.META data of a test client so
>> that i can unit test a view.
>> How do I do this? ie: How do i fake an HTTP header on a test client?
>
> Bump? I just hit this problem, and the above question is the only
> traffic on it...

>From the testing docs [1]:

"""
The extra keyword arguments parameter can be used to specify headers
to be sent in the request. For example:

>>> c = Client()
>>> c.get('/customers/details/', {'name': 'fred', 'age': 7},
...       HTTP_X_REQUESTED_WITH='XMLHttpRequest')
"""

[1] 
http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.get

Yours,
Russ Magee %-)

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to