Вот мой "urls.py":
from django.urls import path
from . import views
app_name = 'News'
urlpatterns = [
path('', views.mainS, name = 'mainS'),
path('/<int:articleId>-<slug:articleSlug>/', views.article_details, name = 'article_details'),
]
В "views.py":
from django.shortcuts import render
from .models import Article
def mainS(request):
articles = Article.objects.order_by("article_datePub")[:10]
return render(request, "News/News.html", {"articles": articles})
def article_details(request, articleId, articleSlug):
return render(request, "News/article_details.html")
В "News.html":
{% block main_block %}
<div class="block-main center-block-main clearfix">
{% for article in articles %}
<div class="block-new">
<a href="{% url 'News:article_details' article.id article.article_slug %}"><div class="new">
<img src="{{ MEDIA_URL }}{{ article.article_img.url }}" alt="">
<div class="text-new">
<div class="text-newh1">
<h1 class="texth1">{{ article.article_title }}</h1>
</div>
<div class="text-newp">
{{ article.article_text }}
</div>
</div>
</div></a>
</div>
{% endfor %}
</div>
{% endblock main_block %}