Why I don't access the {{ user }} variable in template?

40 views
Skip to first unread message

Fellipe Henrique

unread,
Mar 23, 2015, 10:16:00 AM3/23/15
to Django Users
Hello,

I have this settings.py [1], and my CustomUser [2]

When I try to use in my template:

{{ user_first_name }} 

don't show anything... What I miss in these code?

Regards,




T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

aRkadeFR

unread,
Mar 23, 2015, 10:21:04 AM3/23/15
to django...@googlegroups.com
Do you have 'django.contrib.auth.context_processors.auth' in
your context template processor?

{{ user_first_name }} won't work anyway cause the variable
set by the context_processor auth is user. To access a key
or an attribute of a variable, the syntax is:
{{ user.first_name }}

documentation on the django template language:
https://docs.djangoproject.com/en/1.7/ref/templates/api/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF1jwZG2Qwk8n7TGT3ZcZv7FHtnm0MH7r34PkU92N0cBo1%3DgCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Fellipe Henrique

unread,
Mar 23, 2015, 10:29:30 AM3/23/15
to Django Users
Yes, I have django.contrib.auth.context_processors.auth in my Tamplate processor: here is my template processor:

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.tz', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.request', 'core.context_processor.default_proc', 'social.apps.django_app.context_processors.backends', 'social.apps.django_app.context_processors.login_redirect')



sorry, in my template I use this: 
           <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">
                {{ user.first_name }} {{ user.last_name }} <i class="fa fa-angle-down"></i>
            </a>



T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

Daniel Roseman

unread,
Mar 23, 2015, 11:07:23 AM3/23/15
to django...@googlegroups.com
On Monday, 23 March 2015 14:16:00 UTC, Fellipe Henrique wrote:
Hello,

I have this settings.py [1], and my CustomUser [2]

When I try to use in my template:

{{ user_first_name }} 

don't show anything... What I miss in these code?

 
You should show your view. Are you using a RequestContext? 
--
DR.

Fellipe Henrique

unread,
Mar 23, 2015, 12:47:14 PM3/23/15
to Django Users
I found the problem, I was create a custom template context processor, and for some reason I choose one name that override some function in one os 3rd apps I'm using... I change the name of my custom context processor, and works Fine!

Thanks again

T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages