My view's function are not called by urls.py patterns. I can only call them explicitly.
Basic Layout is
--project
----persons
----project
project/urls.py is:
from django.conf.urls import url, include, patterns
from .views import page #irrelevant
# from persons import views as person_views
urlpatterns = patterns('',
url(r'^(?P<slug>[\w./-]+)/$', page, name='page'), #irrelevant
url(r'^$', page, name='homepage'), #irrelevant
url(r'^persons/', include('persons.urls', namespace='persons')), # WORKS
# url(r'^persons/$', person_views.persons, name='persons'), #wont work
# url(r'^persons/add/$', person_views.add_person, name='add_person'), #wont work
)
Everything is ok until this point, since persons.urls is included successfully... But inside:
persons/urls.py:
from django.conf.urls import patterns, url
#from persons.views import index_persons, add_person
from persons import views
#views.index_persons('GET / HTTP/1.0') # >>> WORKS - function called <<< !!!
urlpatterns = patterns('',
url(r'.', views.index_persons, name='index_persons'), # DOES NOT WORK
url(r'^add/', views.add_person, name='add_person'), # DOES NOT WORK
)
I have also tried other regex like:
url(r'*', views.index_persons, name='index_persons'), # DOES NOT WORK
url(r'^$', views.index_persons, name='index_persons'), # DOES NOT WORK
no luck...
My persons/views.py file contains:
def index_persons(request):
print 'WHY???'
def add_person(request):
print 'WHY???'
'WHY???' is normally printed in the console (stdout - since I execute from manage.py runserver), when the index_persons function is called explicitly from persons/urls.py
Any thoughts?