Empty context within template tag render() method after using django.test.client.Client.login() method
Within my integration tests, it appears that after using the login() method of django.test.client.Client the context dict consists only of:
-- [{'False': False, 'None': None, 'True': True}, {}, {}].
If I remove the use of login(), then the request dict consists of:
[{'False': False, 'None': None, 'True': True}, {'object': <User: test1@test.com>, 'user': <User: test1@test.com>, u'view': <accounts.views.AccountDetail object at 0x13bedd0>}, {u'csrf_token': <django.utils.functional.__proxy__ object at 0x1430090>}, {'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x14301d0>, 'user': <django.utils.functional.SimpleLazyObject object at 0x13be390>}, {}, {u'MEDIA_URL': '/media/'}, {'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x1393c10>}, {u'request': <WSGIRequest
path:/accounts/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'sessionid': 'q27przqeidsnfykuufu7m6lo7nw606qw'},
META:{u'CONTENT_TYPE': 'text/html; charset=utf-8',
u'CSRF_COOKIE': u'9mWW7nGMJQAgbs3KBB3oEPofbLBCkLW2',
u'HTTP_COOKIE': u' sessionid=q27przqeidsnfykuufu7m6lo7nw606qw; Domain=None; expires=None; Max-Age=None; Path=/; secure',
u'PATH_INFO': u'/accounts/',
u'QUERY_STRING': '',
u'REMOTE_ADDR': '127.0.0.1',
u'REQUEST_METHOD': 'GET',
u'SCRIPT_NAME': u'',
u'SERVER_NAME': 'testserver',
u'SERVER_PORT': '80',
u'SERVER_PROTOCOL': 'HTTP/1.1',
u'wsgi.errors': <_io.BytesIO object at 0x2358050>,
u'wsgi.input': <django.test.client.FakePayload object at 0x2ac6d90>,
u'wsgi.multiprocess': True,
u'wsgi.multithread': False,
u'wsgi.run_once': False,
u'wsgi.url_scheme': 'http',
u'wsgi.version': (1, 0)}>}, {u'STATIC_URL': '/static/'}, {}]
I noticed the problem when a template tag was trying to access context["request"].path and a KeyError was raised after using login. Both outputs above are the result of printing the context var from within the render() method of a template tag. Any help would be greatly appreciated, as I'm a bit stumped.
Thanks,
Jonathan
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home