Django - Import views from separate apps

from books import views
from contact import views

You are overwriting the name views. You need to import them as different names or as absolute names.

import books.views
import contact.views

... or ...

from books import views as books_views
from contact import views as contact_views

Then use the correct name when defining your URLs. (books.views.search or books_views.search depending on the method you choose)


Disclaimer: Not a Django answer

The problem is with these two lines:

from books import views
from contact import views

The second import is shadowing the first one, so when you use views later you're only using the views from contact.

One solution might be to just:

import books
import contact

urlpatterns = patterns('',
...
(r'^search/$', books.views.search),
(r'^contact/$', contact.views.contact),
...

I'm not sure, but I also think that you don't actually need to import anything and can just use strings in your pattern, something like: 'books.views.search'.


Another possiblity is to follow Simon Visser suggestion:

from books.views import search
from contact.views import contact

Tags:

Python

Django