On Sat, 31 Dec 2005 11:54:57 -0600 Michael Hipp wrote: > Jacob Kaplan-Moss wrote: > > > > On Dec 31, 2005, at 11:02 AM, Michael Hipp wrote: > > > >> How do I put multiple apps on one page/template? > > > > Just use both apps in the same view:: > > > > from django.models.polls import polls > > from django.models.blogs import entries > > > > def my_view(request): > > return render_to_response("template_name", { > > "poll_list" : polls.get_list(), > > "entry_list" : entries.get_list(), > > } > > Thanks. But isn't this going to violate the DRY principle? > > I'm thinking of the example where I have things that I want to appear > around the perimeter of every page on my site representing the output > of numerous independent apps. This would seem to leave me with two > choices: > > 1) Replicate the same code across a lot of different views in > different apps. > > 2) Built a mega-view that is called for every url pattern in which it > is decoded what was really requested and then calls the various views.
Template inheritance should cover the template side of things, and for the views, why not have a single function like that gets the context variable for all the 'extra' things around the edge: c = {"poll_list": polls.get_list()} c.update(get_extra_standard_stuff(request)) render_to_response("template_name", c) The only thing that is then repeated is the call to get_extra_standard_stuff(). And you can eliminate that if you use DjangoContext and this feature: http://www.djangoproject.com/documentation/settings/#template-context-processors Luke -- "Because Your lovingkindness is better than life, My lips shall praise You." (Ps 63:3) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/