开发者

Django: Form in your Site Base template

开发者 https://www.devze.com 2023-04-06 21:03 出处:网络
I need to create a form, not search, but a kind of profile switcher that will be present in the site base.

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 imple开发者_C百科ment 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.


Looks like you need context processor


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消