# Django doubles path of link (wrong urls.py configurations?)

**URL:** <https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533>\
**Category:** Templates & Frontend\
**Created:** [August 21, 2022, 4:09pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533 "2022-08-21T16:09:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marlon-888](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marlon-888/32/9778_2.png) [@marlon-888](https://forum.djangoproject.com/u/marlon-888)\
**Post date:** [August 21, 2022, 4:09pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533/1 "2022-08-21T16:09:07Z")

</div>

Hi Everyone,

I am currently working on a website. Up in the Navigation bar are several links  
like “Home” “Contact” etc. One of my links is called “Teilnehmerliste”.  
If I now click on “Teilnehmerliste” in the navigation bar, at first I get to my page successfully. But if I then want to click another link, Django doubles my path. For example, when I click “Contact”, Django calls the following link:  
“WEBSITENAME/teilnehmerliste/contact” instead of “WEBSITENAME/contact”. And from then on nothing works anymore (Page not found). My HTML file for the link (Teilnehmerliste) is called “teilnehmerliste.html” and is located in the subfolder “teilnehmerliste” which in turn is in the “templates” folder. And the app folder is called “manage\_teilnehmerlisteliste\_app”.

**My current configurations look like this:**

_urls.py (from the project folder):_

```auto
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('teilnehmerliste/', include('manage_teilnehmerliste_app.urls')),
    
    ]

```

_urls.py (from the app folder):_

```auto
from django.urls import path
from . import views

urlpatterns = [
    
    path('', views.teilnehmerliste, name='teilnehmerliste'),

```

_views.py (from the app folder):_

```auto
from django.shortcuts import render, redirect
from .models import ManageTeilnehmerListe

# Create your views here.

def teilnehmerliste (request):
    context = ManageTeilnehmerListe.objects.all()
    

    if request.method == 'POST':
        new_participant = ManageTeilnehmerListe(
            title = request.POST['title']

        )
        new_participant.save() 
        return redirect('/teilnehmerliste')

    return render(request, 'teilnehmerliste/teilnehmerliste.html', {'contexts': context})

```

_settings.py Datei:_

```auto
TEMPLATES = [
    {
	...
        'DIRS': [BASE_DIR/'templates'],
	...
]

INSTALLED_APPS = [
    ...
    'manage_teilnehmerliste_app',
    ...
]

```

_models.py (aus dem App-Ordner):_

```auto
from django.db import models

class ManageTeilnehmerListe(models.Model):
    title = models.CharField(max_length=50)

    def __str__ (self):
        return self.title

```

PS: By the way, I’ve already looked at many sites that deal with the problem.

Where is the mistake?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 21, 2022, 4:17pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533/2 "2022-08-21T16:17:30Z")

</div>

This is almost certainly a template error.

Please post the template that is used to create the page creating the link with the wrong url being generated.

---

<div class="post-metadata">

**Author:** ![marlon-888](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marlon-888/32/9778_2.png) [@marlon-888](https://forum.djangoproject.com/u/marlon-888)\
**Post date:** [August 21, 2022, 4:39pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533/3 "2022-08-21T16:39:03Z")

</div>

here is the HTML-Part from the html-template. I guess the CSS-Part is not important:

```auto
<body id="ixck">
    <header id="irzc" class="header-banner">
      <div id="iyxg" class="container-width">
        <div id="i1ei" class="logo-container">
        </div>
        <div class="clearfix">
        </div>
        <div id="is2u1" class="row">
          <div id="i29jk" class="cell">
            <div id="il0f" class="logo">
              <span id="i3pqk">Testsite 123</span>
              <br/>
            </div>
          </div>
        </div>
        <div id="iiwyf">
          <span></span>
        </div>
        <div id="ioufd">
          <i>connecting &amp; expanding through music...
          </i>
          <br/>
        </div>
        <div id="ipkxf" class="row">
          <div id="imkmk" class="cell">
            <div id="iftzx" class="menu-item">
              <a href="" id="izskm">Home</a>
              <br/>
            </div>
            <div id="i8mxq" class="menu-item">
              <a href="teilnehmerliste" id="i9flg">Teilnehmerliste</a>
            </div>
            <div id="imvce" class="menu-item">
              <span id="i5hie"><a href="location" id="idx6h">Location &amp; Wegbeschreibung</a></span>
              <br/>
              <br/>
            </div>
            <div id="i8ejo" class="menu-item">
              <a href="qrcode" id="i7tyo">QR-Code</a>
            </div>
            <div id="i0nfl" class="menu-item">
              <span id="itjel"><a href="contact" id="ihtxk">Kontakt</a></span>
              <br/>
            </div>
          </div>
        </div>
      </div>
      <div id="iewyh" class="row">
      </div>
      <div id="idjhh" class="row">
        <div id="ikgjr" class="cell">
          <div id="innnd" class="row">
            <div id="i6j6g" class="cell">
              <form action="" id="ilyvqf" method="POST" class="form">
                {% csrf_token %}
                <div class="form-group">
                  <label class="label">Name</label>
                  <input type="text" name="title" placeholder="Type here your name" id="i7kr9a" class="input"/>
                </div>
                <div class="form-group">
                </div>
                <div class="form-group">
                </div>
                <div class="form-group">
                  <button type="submit" id="ijhat9" class="button">Send</button>
                </div>
                <ul id="myUL-2"> 
                  {% for context in contexts reversed %}
                  <li id="i9fgpi">{{context.title | title}} 
                    <span class="close"><a href="delete/{{context.id}}" id="iwd8hq">Delete</a></span>
                  </li>
                  {% endfor %}
                </ul>
              </form>
            </div>
          </div>
        </div>
      </div>
    </header>
    <section id="i3pjs" class="flex-sect">
      <div id="igrwj" class="container-width">
        <div id="ilrt5" class="flex-title">
          <span id="itpjr">Achtung:</span> Die Location für unser gemeinsames 
          <br/>Trommeln
          kann sich manchmal ändern. 
          <br/>Schaue dazu unter 
          <a href="" id="i74xq2">Location &amp; Wegbeschreibung</a>, 
          <br/>um auf dem neusten Stand zu sein!
          <br/>
        </div>
      </div>
    </section>
    <footer id="i2xz7k" class="footer-under">
      <div class="container-width">
        <div id="ittc2a" class="footer-container">
          <div id="izic9p" class="foot-list-item">Home
          </div>
          <div id="izi4et" class="foot-list-item">Teilnehmerliste
          </div>
          <div id="ipffel" class="foot-list-item">QR-Code
          </div>
          <div id="io8gt8" class="foot-list-item"> Location &amp;
            <br id="ij7sk-2" draggable="true"/>Wegbeschreibung
          </div>
          <div id="iq3kb" class="foot-list-item">Kontakt
          </div>
        </div>
      </div>
    </footer>
  </body>

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 21, 2022, 4:55pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533/4 "2022-08-21T16:55:52Z")

</div>

The issue here is that the links you are creating are relative to the current path.

So if your current path is “/xyz”, then this link:

> [@marlon-888](#):
>
> `<a href="contact" id="ihtxk">`

is a reference to “/xyz/contact”.

You would need to make that link “/contact” in order for it to be an absolute url.

However, what you really should be doing in your template is using [the `url` tag](https://docs.djangoproject.com/en/4.1/ref/templates/builtins/#url) and identifying the link by name.

---

<div class="post-metadata">

**Author:** ![marlon-888](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/marlon-888/32/9778_2.png) [@marlon-888](https://forum.djangoproject.com/u/marlon-888)\
**Post date:** [August 21, 2022, 6:38pm UTC](https://forum.djangoproject.com/t/django-doubles-path-of-link-wrong-urls-py-configurations/15533/5 "2022-08-21T18:38:06Z")

</div>

Wow! Thanks for the clarification and the solution 😉  
The issue cost me a lot of time and would have done even more…so thanks again.

Adding the “/” to the links in the HTML file now works.

Next I will deal with how to use the URL tags…
