When to use a context processor

I have a website on which I include userBox with some data displayed for each registered user (your name, avatar, etc.). From what I already know about django, it seems obvious that I have to add the request for the user to the context processor (so that I can use the variable {{user}}in this included userBox). But when using the django-lfs store, I noticed that a variable is used in its templates {{ user }}, which is not added anywhere in context processors and template tags. Is there any other way to get the user in my template than those 2?

+2
source share
2 answers

He added

django.contrib.auth.context_processors.auth

: - , context_processor.

+2

:

{{ user.get_profile.foobar }}, foobar - . AUTH_PROFILE_MODULE = 'yourprofileapp.YourProfileModel' settings.py. . http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

0

Source: https://habr.com/ru/post/1789801/


All Articles