On Thu, Oct 23, 2008 at 11:41 AM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> By using pdb post mortem, I found out that the request.META dictionary
> doesn't actually have 'REMOTE_ADDR' in it. Settings.INTERNAL_IPS is
> '127.0.0.1'. So then get() returns None, and the error comes from
> python trying to evaluate None in '127.0.0.1'. Should the test client
> be setting this value? Is there something in my code or configuration
> that needs to change to set that?
>

I'm a little puzzled because I cannot recreate the error you see.  From your
traceback it appears like it might be resulting from having DEBUG set to
True when running the test, but even using a settings file where DEBUG is
True, I do not see that error:

>>> from django.conf import settings
>>> settings.DEBUG
True
>>> from django.test.client import Client
>>> c = Client()
>>> c.get('/')
<django.http.HttpResponse object at 0x87dd0ec>
>>>

So I am not sure why you see it.  However, the lack of a REMOTE_ADDR setting
in the test client environment has been reported in a ticket:

http://code.djangoproject.com/ticket/8551

so you could probably either use the workaround mentioned there or try
running with the little patch in the ticket and see if it fixes your case.

Karen


>
> On Oct 23, 9:17 am, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
> > I found this problem while trying out the django test client:
> >
> > $ ./manage.py shell>>> from django.test.client import Client
> > >>> c = Client()
> > >>> c.get('/')
> >
> > Traceback (most recent call last):
> >   File "<console>", line 1, in <module>
> >   File "/var/lib/python-support/python2.5/django/test/client.py", line
> > 265, in get
> >     return self.request(**r)
> >   File "/var/lib/python-support/python2.5/django/core/handlers/
> > base.py", line 86, in get_response
> >     response = callback(request, *callback_args, **callback_kwargs)
> >   File "/path/to/website/views.py", line 12, in index
> >     context_instance=RequestContext(request))
> >   File "/var/lib/python-support/python2.5/django/template/context.py",
> > line 105, in __init__
> >     self.update(processor(request))
> >   File "/var/lib/python-support/python2.5/django/core/
> > context_processors.py", line 34, in debug
> >     if settings.DEBUG and request.META.get('REMOTE_ADDR') in
> > settings.INTERNAL_IPS:
> > TypeError: 'in <string>' requires string as left operand
> >
> > This is probably a mistake in my configuration, but it may be a bug.
> > It throws the same error regardless of which path I try to get, or if
> > I use c.post instead. Can anyone figure this out?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to