[Fixed]-I can't get the user in django templates

1👍

Make sure you pass the request context in the view, it’s what adds the user to the context…

from django.template import RequestContext

def some_view(request):
  form = None
  # request.user accesses user here
  return render_to_response('some_template.html', {'form':form}, context_instance=RequestContext(request))

Now in the template you can use:

{% if request.user.is_authenticated %}{{ request.user.email }}{% endif %}

Leave a comment