When I try to load a page, I get another page instead... I try to load a page called wikiPage as shown in my urls description that follows, but I get another url patterns linking to a view called newPageb instead, though the two urls have same parameters and the one that is first in order gets called, But how do I make them distinct where I can call them irrespective of order.
Here is my urls.py...
app_name= "encyclopedia"
urlpatterns = [
path("", views.index, name="index"),
path("randomPage", views.randomPage, name="randomPage"),
path("<str:pagetitle>", views.newPageb, name="newPageb"),
path("<str:pagetitle>", views.wikiPage, name="wikiPage"),
path("<str:z>", views.wikiPage, name="wikiPage"),
path("newPage", views.newPage, name="newPage"),
path("<str:pageSearch>", views.search, name="search"),
path("", views.search, name="search")
Here are the conflicting views..
def newPageb(request, pagetitle)
...
...
def wikiPage(request, pagetitle):
...
...
and here is the template where the pagetitle parameter was declared
{% extends "encyclopedia/layout.html" %}
"
{% block title %}
Encyclopedia
{% endblock %}
{% block body %}
<h1> {{title}} </h1>
<ul>
{% for pagetitle in entries %}
<li>
<a href="{% url 'encyclopedia:wikiPage' pagetitle=pagetitle%}"> {{ pagetitle }} </a>
</li>
{{entrie|safe}}
{% endfor %}
</ul>
{% endblock %}
because you have two routes that match, because of which django chooses the first suitable template for the url address and does not look at the following addresses.
to solve this problem you need to change one of the addresses. example