Hi I am a beginner with django and all I have left to deploy the site is a stupid url conf problem. I have a simple site with 5 pages that are home,contact,about,reasons, and benefits
. Simple right, url conf will be (r'^home/$',index)
, and as follows for the rest of the pages. Here is the problem when I go to the home page /home/
fine. Now go to any other page on the navigation like /reasons/
or /about/
,they dont get called like that, instead get called /home/reasons/
or /home/about/
. Even more so if from /home/about/
I click back to home the call is /home/about/home
. As you see this goes on forever. How can it be where every request to a page is a simple /about/
or /contact/
instead of /home/contact or /home/about
.
I had defined one that went /home/contact/home/home/about/reasons/home
I cant possibly put all those in urlconf
Note: this is all being ran on django dev server
If your urls look like this:
(r'^home/$', myapp.views.index)
then use it in template as:
<a href="{% url myapp.views.index %}>some text</a>
to avoid wrong interpretation. Django will do the rest.
For Django 1.5 use
<a href="{% url 'myapp.views.index' %}>some text</a>