Django: Form in your Site Base template
-
25-01-2021 - |
Question
I need to create a form, not search, but a kind of profile switcher that will be present in the site base.
Just wondering what's the best way of going about this? I'm not very familiar with middlewares but this sounds like the time to investigate it?
Alternatively, I was thinking I could load the form from a templatetag?
I'm just looking for different ways to implement this site wide form. Thanks.
A good example would be Github. The switch account context gives you different pages/accessibility based on your current account context.
Solution
Looks like you need context processor
OTHER TIPS
You can write a template including a form, and include this template in your base.html. You have access to the user profile in the template via
{{ request.user.get_profile }}
It this what you need?