In Django, is it not possible to have multiple views imports from the urls.py?
For example, I have the following code in urls.py:
from mysite.books import views
from mysite.contact import views
urlpatterns = patterns('',
(r'^contact/$', views.contact),
(r'^search/$', views.search),
)
However, the server displays an error unless I disable one of the couples. So my questions are threefold:
1) Is it not possible to have multiple import views statements?
2) How to get around this?
3) What is best practice for where to put all your views.py? One file? Multiple files? etc.
Thank you.
1) Yes it is.
2)
3) Per Django docs, “This code can live anywhere you want, as long as it’s on your Python path.”. I keep all the app views in
app/views.py