Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the current logged user in the template #605

Closed
tcosta84 opened this issue May 1, 2015 · 2 comments
Closed

Get the current logged user in the template #605

tcosta84 opened this issue May 1, 2015 · 2 comments

Comments

@tcosta84
Copy link

tcosta84 commented May 1, 2015

I'm trying to get the current user object in my templates after successfully logging in with Twitter but it's not working.

Here's what I'm trying to do in my templates:

Welcome, {{ request.user.first_name }}

I already have the "django.core.context_processors.request" on TEMPLATE_CONTEXT_PROCESSORS. I have already tested with no success putting it before and after:
'social.apps.django_app.context_processors.backends',
'social.apps.django_app.context_processors.login_redirect',

Am I doing something wrong?

@tcosta84
Copy link
Author

tcosta84 commented May 1, 2015

It happens you don't need to use "django.core.context_processors.request" to achieve that. The issue was that I was using "render_to_response" instead of "render".

And in your template you want to use:

{{ user.first_name }}

instead of

{{ request.user.first_name }}

@tcosta84 tcosta84 closed this as completed May 1, 2015
@tcosta84
Copy link
Author

tcosta84 commented May 1, 2015

It happens you don't need to use "django.core.context_processors.request" to achieve that. The issue was that I was using "render_to_response" instead of "render".

And in your template you want to use:

{{ user.first_name }}

instead of

{{ request.user.first_name }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant