P
P
Python Newbie2021-10-06 19:22:47
Django
Python Newbie, 2021-10-06 19:22:47

How to make a separate page for each product in django?

I have a test site:

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="home" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    


<h1>Список статьей</h1>


    <div>
        <img src="/media/photos/2021/10/06/e68cc68e-7b07-41c2-9520-4b315072a8a6_3Iwmjyw.jpg" width="100" height="100" alt="Test">
        <h3><a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ">Test</a></h3>
        <div>Hello World!</div>
        <p>Написано 6 октября 2021 г. 16:13</p>
    </div>
<hr>


</body>
</html>


How can I make it so that when you click on a link, you are taken to an automatically generated page for each card?

For example, I created 10 cards and I need 10 such auto-pages at once, which you will go to by clicking the link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2021-10-06
@Levman5

# добавить путь в urls.py с ключем (к примеру lecture_id), 
path('lections/<int:lecture_id>/', views.lections_detail, name='Curr_lecture'), # lecture_id
# views.py в представлении, которое вызывает этот путь, передавать этот ключ (названия должны быть идентичны)
def lections_detail(request, lecture_id): # lecture_id
    lect = Lecture.objects.get(id=lecture_id)

And then output the data as usual

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question