This view function:
@login_required
def dashboard(request):
from myproject.myapp.models import UserProfile
k = UserProfile.objects.get( user=request.user.pk ).known
return render_to_response('dashboard.html', {'KNOWN': k, , context_instance=RequestContext(request))
Passes to this template:
{% if user.is_authenticated %}
{{ user.username }}
{% else %}
Login link
{% endif %}
{{ KNOWN }}
- I have already logged in.
- Page does not redirect to LOGIN_URL (so therefore @login_required thinks im logged in I guess)
- {{ KNOWN }} renders perfectly OK
- {{ user.username }} doesn't appear
How is this possible? Surely if login_required works, and it managed to grab KNOWN, therefore user must exist somewhere?
How can I debug this?
:-)
UPDATE: If I remove:
TEMPLATE_CONTEXT_PROCESSORS = ('django.core.context_processors.request',)
From settings, it works.
However, by removing that, other pages which use {{ request.get_full_path }} in templates don't load.
Eeek.
UPDATE 2:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",)
If you just add the request line on its own, it disables all the others which are defaults. D'Oh!
UPDATE 3: Thought that would fix it, unfortunately still not working.
UPDATE 4: Spotted typo elsewhere, can confirm that Mark Lavin's answer fixed it :)