Monday, March 23, 2015

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

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

On Mon, Mar 23, 2015 at 11:21 AM, aRkadeFR <contact@arkade.info> wrote:
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/


On 03/23/2015 03:15 PM, 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?

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
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/5510214C.4020505%40arkade.info.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CAF1jwZFFkppQMXTxFMVhp_E8YANwwW0pAvsW7Yw%3Dp%3DXYAnTPWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment