Why not include url regular expressions in django check for end of line

Say you have a full url localhost:thisdir/callview/

I noticed that in the urls.py file, the included namespace is written as:

(r'^thisdir/', include('thisdir.urls', namespace='thisdir)),

where the initial line is checked, but does not end, and the view call is executed as:

(r'^callview/$', 'thisdir.views.index', name='myview')

with $ to check the end of the line. If the include pattern breaks "thisdir /" into the full URL to check this section first, and I thought that it checks each section of the line at a time (so that "thisdir /" is at the end of the line), why I never see(r'^thisdir/$', ...)

Thank you

+4
source share
1 answer

https://docs.djangoproject.com/en/1.8/topics/http/urls/

, $( ), . , Django include() (django.conf.urls.include()), URL-, , URLconf .

$, - , URL-, include regex.

, , , URL-.

(r'^thisdir/$', <include>) URL-, thisdir/ - $. URL-, thisdir/foobar/, include.

, $ , /thisdir/<anything> , , URL-.

+9

All Articles