user1908488
user1908488

Reputation: 309

Sending data to Django template

A part of my website whose URL pattern starts with a fixed string manage eg: 'example.com/manage/post', 'example.com/manage/user' requires that certain information associated with the user is displayed on every page that belongs to this section of the website.

Do I have to return this information inside every view method to do so?

This information is not maintained in the User profile. It is maintained in a model outside the User Profile. There is a many to one relationship from this model to the User profile.

Upvotes: 1

Views: 114

Answers (1)

Michael Mior
Michael Mior

Reputation: 28762

Are you talking about the user viewing the page? If so, just add the following to TEMPLATE_CONTEXT_PROCESSORS in your settings.py.

'django.contrib.auth.context_processors.auth'

This will give you access to the current user as a variable called user in all your templates.

Upvotes: 1

Related Questions