views:

32

answers:

2

I have an app called lastapp that I would like it to be viewable on all pages. It renders base.html so it's available on all apps. So far I've tried adding it to the urls.py like this:

urlpatterns = patterns('',   
    (r'^first/$', firstapp, lastapp),
    (r'^last/$', lastapp),
)

But when I go to /first/ it gives me the error: Error, 'function' not iterable. It shows fine when going to /last/. If I remove lastapp from the /first/ site in urls.py, then firstapp shows fine also. Is there a special way to do this? Thanks in advance.

A: 

I think what you need is probably Middleware.

Matthew J Morrison
+1  A: 

What exactly are you trying to do?

All installed applications are available in your project, but the application by it self does not return any data to the template, that's the job of the views which are part of that application.

My guess is that firstapp and lastapp are rather views then apps.

If that is a case, context processors make it possible to always pass certain data to a template.

So, create a context processor out of lastapp and set it in TEMPLATE_CONTEXT_PROCESSORS in settings.py.

rebus
Yes, both lastapp and firstapp are views. All lastapp does is fetch data from a model in firstapp. Thanks for pointing out context processors.
Ping Pengũin