Я новичок в Джанго. Моя проблема в том, что когда я нажимаю на заголовок, который находится в .html, он направляет меня на этот URL; http://localhost:8000/aba/R%C3%BCyada%20Aba%20G%C3%B6rmek
в этом URL я получаю сообщение об ошибке; Страница не найдена 404
Вот я хочу сделать; Когда я нажимаю на заголовок, я хочу динамически показывать детали моей статьи
dreamarticle / urls.py
from django.contrib import admin
from django.urls import path, re_path
from dreamarticle import views
app_name = "Dreamarticle"
urlpatterns = [
re_path('/aba/(.*?)/',views.aba,name="aba"),
path('a/',views.a,name="a"),
]
блог / urls.py
from django.contrib import admin
from django.urls import path,include
from article import views
from dreamarticle import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.index, name="index"),
path('articles/',include("article.urls")),
path('user/',include("user.urls")),
path('dreamarticle/',include("dreamarticle.urls")),
]
dreamarticle / views.py
def aba(request, title):
context = dict()
context.update(
dreamarticlesaba=get_object_or_404(dreamarticle, title=title),
)
return render(request, "aba.html", context)
aba.html
{% extends "layout.html" %}
{% block body%}
<!-- Content here -->
<br>
<div class="container">
<div class="row">
{% if dreamarticlesaba %}
{% for dreamarticle in dreamarticlesaba %}
<div class="col-md-12 dreamdetail">
<h1>{{dreamarticle.title}}</h1>
<hr>
<p>{{dreamarticle.content|safe|escape}}<p>
</div>
{% endfor %}
{% endif %}
</div>
</div>
a.html
{% extends "layout.html" %}
{% block body%}
{% include "includes/searchbar.html" %}
<!-- Content here -->
<br>
<div class="container">
<div class="row">
{% if dreamarticles %}
{% for dreamarticle in dreamarticles %}
<div class="col-md-4 text-center bg-primary">
<a href="/aba/{{dreamarticle.title}}" class="titlerenk text-white"><br><b>{{dreamarticle.title}}</b></a>
<b>{{dreamarticle.title}}</b>
</a>
</div>
{% endfor %}
{% endif %}
</div>
</div>
{% endblock body%}
Страница не найдена (404)
Request Method: GET
Request URL: http://localhost:8000/aba/R%C3%BCyada%20Aba%20G%C3%B6rmek
Using the URLconf defined in blog.urls, Django tried these URL patterns, in this order:
admin/
[name='index']
articles/
user/
dreamarticle/
The current path, aba/Rüyada Aba Görmek, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.