Django - Tips to avoid repeating code in views
- by D Roddis
I'm moving from a PHP background into Django development via python, mostly for the sake of tackling a MVC (or MVT) that I feel makes the most sense, although in this pattern I've started to notice a lot of repeated code in my views.
For example, when logged in I have information regarding the user that I would like to appear on every page, although when using render_to_response and in every view this is required I have to grab the information and pass it to the render_to_response function.
I'm wondering what would be the most efficient way to cut down on the duplicate code which would in essence be required in all views in a particular app.
Thanks in advance.