0👍
✅
FWIW, an update to Django 1.2 (I was running 1.1.1 before) fixed it. I have no idea what was broken there, considering when I last ran that test suite about 2 weeks ago, it worked great.
👤Fred
1👍
Just happened to me when retesting an app that has been working and forgotten for some months.
The solution (apart from updating to Django 1.2) is Patch #11821. In short, Python 2.6.5 has some bugfix in the Cookie module, triggering an edge case bug in the test client.
- [Django]-Django ORM – Grouped aggregates with different select clauses
- [Django]-Why does the Django Atom1Feed use atom:updated instead of atom:published?
- [Django]-How can I create sophisticated Django Model Validation for Django Admin?
- [Django]-Get method classname inside decorator at __init__ in python
0👍
I use RequestContext
to get the logged in user into the template context.
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
@login_required
def index(request):
return render_to_response('page.html',
{},
context_instance=RequestContext(request))
and in the template
{% if user.is_authenticated %} ... {{ user.username }} .. {% endif %}
This works as expected (I don’t get to this page without logging in, and when I get there, the username is present in response.content
) when driven through the test client.
- [Django]-Resize image in the views and load it in the templates in django
- [Django]-Virtualenv, sys.path and site-packages
- [Django]-Internet Explorer does not talk with django dev server
Source:stackexchange.com