I have a site on which I'm including a userBox with some data shown for each logged user (your name, avatar etc). From what I already know about django it seems obvious, that I should add query for user to context processor (so that I can use{{user}}
variable in this included userBox ). But while using django-lfs shop I've noticed, that it's templates are using {{ user }}
variable which is nowhere added to context processors nor template tags. Is there any other way to obtain user in my template than those 2 ?
相关问题
- Django __str__ returned non-string (type NoneType)
- Django & Amazon SES SMTP. Cannot send email
- Django check user group permissions
- Django restrict pages to certain users
- UnicodeEncodeError with attach_file on EmailMessag
相关文章
- Profiling Django with PyCharm
- Why doesn't Django enforce my unique_together
- MultiValueDictKeyError in Django admin
- Django/Heroku: FATAL: too many connections for rol
- Django is sooo slow? errno 32 broken pipe? dcramer
- Django: Replacement for the default ManyToMany Wid
- Upgrading transaction.commit_manually() to Django
- UnicodeEncodeError when saving ImageField containi
It's added by
And the answer for the question is: if you need something to be in every template, you should use context_processor.
using additional user data in your templates is easy:
{{ user.get_profile.foobar }}
where foobar is one of your profile's fields. But make sure to have setAUTH_PROFILE_MODULE = 'yourprofileapp.YourProfileModel'
insettings.py
. For more info see http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users