Answer the question
In order to leave comments, you need to log in
How to make the block visible only to the selected user?
There will be a small block on the top of the site (some task is written). This block must be visible to the selected user. And if possible, in this block, but with a different text, to another selected user. There are 3 or more store(s). In order to display one task on one computer, the other one, and let them drink tea in the third))) The site is written in Django. Is there anywhere else to read about it? Thanks in advance for the replies and advice.
Answer the question
In order to leave comments, you need to log in
Well, I would probably pass the id of the selected users to the context DetailView, for example context["user1"] == 45 in the get_context_data procedure, and in the template I would use
{% if request.user.id == user1 %}
to display a block for one user
{% elif request.user.id == user2 %}
output block for another user
{% endif %
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question