Ok. I'm replying inline: On 24 Aug 2014 18:43, "Jagger" <zun...@gmail.com> wrote: > > The link is in the base.html of spweb app: > > <a class="mainmenuitemlink" href="index">NEWS</a> > This link is relative so the browser will append the href attribute to the present URL. You should change it to: <a class="mainmenuitemlink" href="/index/">NEWS</a>
>> >> On 24 Aug 2014 12:30, "Jagger" <zun...@gmail.com> wrote: >>> >>> Hi Everyone! >>> >>> >>> >>> I use Python 2.7 and Django 1.6 on Xubuntu 14.04. >>> >>> >>> I'm a beginner. My problem is: >>> >>> >>> The root URLConf: >>> >>> from django.conf.urls import patterns, include, url >>> >>> >>> from django.contrib import admin >>> >>> >>> admin.autodiscover() >>> >>> >>> urlpatterns = patterns('', >>> >>> url(r'^admin/', include(admin.site.urls)), >>> >>> url(r'^', include('spweb.urls')), >>> >>> ) >>> >>> >>> >>> The URLConf of spweb app: >>> >>> >>> from django.conf.urls import patterns, url >>> >>> >>> from spweb import views >>> >>> >>> urlpatterns = patterns('', >>> >>> url(r'^$', views.index, name='index'), >>> >>> url(r'^index/$', views.index, name='index'), Why did you give the 2 patterns the same name ('index')? Because Django can automatically fill in the URL linked to a name by using the url template tag: <a class="mainmenuitemlink" href="{% url 'index' %}">NEWS</a> >>> >>> url(r'^contact/$', views.contact, name='contact'), >>> >>> ) >>> >>> >>> In a browser the first click on a link link points to http://127.0.0.1:8000/index (OK, that's correct. This is what I expect to happen.) >>> >>> But the second click on the same link points to http://127.0.0.1:8000/index/index (That's wrong. Why did the url change???) BTW note that http://example.com is different fron http://example.com/. >>> >>> >>> >>> Thans for your answers! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BWjgXPZG%2BJCSJfLLhdQSkD68T4Kvb4vjLkMErYYfz-mpbHdLQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.