On Sat, May 16, 2009 at 10:59 AM, zayatzz <alan.kesselm...@gmail.com> wrote:
> > Hello > > I have several views that pass same info into templates. If i want to > change information that gets passed into template then i have to > change several views to get system up to date and this is not good. > Its common sense to replace them with one function instead. > > Where and how should i write functions like that? Where is not such a big deal. You could write a function in view that you reuse multiple times (maybe start its name with an _ to show that it is not a public function cq just a helper function), or you could put it into a util.py file and import it in your views.py How totally depends on what the function does, what is the block of code that comes back in every view? Second question is about handling common views. Basically i have one > big template which holds general information of the site - metastuff, > css, scripts and generic markup - page template. Then there are > several views/templates that extend the page template. > > Page template is something like this: > <markup> > {% block one %} > {% endblock %} > {% block two %} > {% endblock %} > {% block three %} > {% endblock %} > {% block frour %} > {% endblock %} > </markup> > > If any of those blocks is in use then other are mostly empty so they > generate no additonal unnecessary markup. Is this okay or is there > another way to do it? You can than probably have several templates that extend the base template (with all your <head> etc.) and have them all use just one block, content for example, from your base template. Tino --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---