On Thu, Mar 19, 2009 at 11:40 AM, Johan <djjord...@gmail.com> wrote: > > Given: > >>>> from django.test.client import Client >>>> c = Client() >>>> c.post('/register/',{username=username,password=password}) > > Traceback (most recent call last): > ... > KeyError: 'HTTP_HOST' > > Part of the register view code contains the following: > > ... request.META["HTTP_HOST"] ... > > The problem seems to be that the test client does not inject the META > (Or at least some of the META) data. > > Am I using the wrong construct? If so how do I get around this > problem? >
See this thread from a few days ago: http://groups.google.com/group/django-users/browse_frm/thread/ab3c16762a4aceab The last example Russell gave there: > or by providing an 'extra' argument to an individual request: > > >>> client.get('/foo/bar/',extra={'HTTP_HOST':'example.com'} actually results in a 'extra' key whose value is a nested dictionary in the request.META dictionary. Use >>> client.get('/foo/bar/', HTTP_HOST='example.com'} instead. HTH, -- Ramiro Morales http://rmorales.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---