1👍
You have $
signs at the end of urls in root
‘s urls.py
. That means that url has to match exactly (not just beginning). So in your example url matches to second entry in root
‘s urls.py
and empty string is passed to with_Time
‘s urls.py
so it will match first entry and display time.
If you are including other urls files you normally want to use regex without $
, so it will match the beginning of url and remaining will be passed to included urls file.
To correct your example use this for root
‘s urls.py
:
url(r'^dealwith_Time/',include('dealwith_Time.urls')),
note that I’ve removed $
, so /dealwith_time/12
and /dealwith_time/
will be both matched and 12
in first case will be passed to the next level.
And use this for with_Time
‘s urls.py
:
url(r'^$', 'dealwith_Time.views.current_datetime'),
url(r'^12$', 'dealwith_Time.views.hour_ahead'),
note that I’ve removed /
in second line as it will be stripped in root’s urls.py
.
1👍
You have to change
url(r'^dealwith_Time/$',include('dealwith_Time.urls')),
for
url(r'^dealwith_Time/',include('dealwith_Time.urls')),
The $ sign overrides dealwith_Time/12
and would override anything that came after the foward slash sign.
Take a look at Regular Expressions.
- [Answered ]-Form is not appearing
- [Answered ]-Error installing MySQL-python with pip
- [Answered ]-Prevent adding duplicate data from excel forms imported into db