Creating simple app using GAE / Django-nonrel (I don't think the problem is specific to GAE or the nonrel fork, most likey PEBKAC as python/django noob and would occur on basic django installation).
I am using django.contrib.auth for authentication.
In settings.py
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', )
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request', )
I've created superuser with manage.py
I've got following in templates base.html which is used in others by {% extends 'base.html' %}
{% if user.is_authenticated %}
Hello {{ user.username }}
[<a href="{% url django.contrib.auth.views.logout %}">sign out</a>]
{% else %}
[<a href="{% url django.contrib.auth.views.login %}">sign in</a>]
{% endif %}
And in urls.py the standard authentication stuff (from django.contrib.auth.forms import AuthenticationForm etc).
Problem is that I can authenticate successfully, username/password checking is working (can't use incorrect user/pwd) and I am authenticated on the admin pages - but not on the other pages - or rather I am but user is null (None).
I think that "django.contrib.auth.context_processors.auth" is the magic that makes this happen but that is setup in settings.py as shown above.
Any tips on how to track this problem down?
EDIT (expanding on Daniels answer as as can't do code formatting in comments)
in views.py I had :-
def detail(request):
obj = get_object_or_404(MyModel, pk=some_id)
return render_to_response('myapp/index.html', {'MyModel': obj})
Should have been
return render_to_response('myapp/index.html', {'MyModel': obj}, RequestContent(request))
Are you using a RequestContext to render your template? Context processors aren't applied unless you do.
See django-postman discards RequestContext . With that you're assigning TEMPLATE_CONTEXT_PROCESSORS 2 items, you're overriding the default items.