A
A
artchis2020-11-29 16:34:32
Django
artchis, 2020-11-29 16:34:32

Why does it display something that is not in the code?

Why is the main page displayed when opening different pages, although I switched to another one?

indexhtml

<!doctype html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Pdsaldsafd</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

</head>
<body>
            <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
          <a class="navbar-brand" href="/">PLAYTI</a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>

          <div class="collapse navbar-collapse" id="navbarsExampleDefault">
            <ul class="navbar-nav mr-auto">
              <li class="nav-item active">
                <a class="nav-link" href="/">Главная <span class="sr-only"></span></a>
              </li>
              <li class="nav-item active">
                <a class="nav-link" href="psd">PSD макеты <span class="sr-only"></span></a>
              </li>
              <li class="nav-item active">
                <a class="nav-link" href="puk">Паки для ютуба <span class="sr-only"></span></a>
              </li>
              <li class="nav-item active">
                <a class="nav-link" href="php">Скрипты сайтов <span class="sr-only"></span></a>
              </li>
              <li class="nav-item active">
                <a class="nav-link" href="sale">Товары Aliexpress <span class="sr-only"></span></a>
              </li>
            </ul>
            <form class="form-inline my-2 my-lg-0">
              <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="">
              <button class="btn btn-secondary my-2 my-sm-0" type="submit">Поиск</button>
            </form>
          </div>
        </nav>


            <section class="jumbotron text-center">
                <div class="container">
                  <h1>PLAYTI</h1>
                  <p class="lead text-muted">PLAYTI - сайт для ютуберов, дизайнеров и программистов.<br>Тут вы найдёте PSD макеты, паки для ютуба и скрипты для сайтов.</p>
                  <p>
                    <a href="https://vk.com/digitscript" class="btn btn-primary my-2">Группа ВКонтакте</a>
                    <a href="https://t.me/play_ti" class="btn btn-secondary my-2">Канал в Telegram</a>
                  </p>
                </div>
              </section>


                        <div class="col-md-4">
                  <div class="card mb-4 shadow-sm">
                    <svg class="bd-placeholder-img card-img-top" width="150px" height="225px" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Thumbnail"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
                    <div class="card-body">
                      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                      <div class="d-flex justify-content-between align-items-center">
                        <div class="btn-group">
                          <button type="button" class="btn btn-sm btn-outline-secondary">Скачать</button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>

                    <div class="wrapper">
                        <div class="content">
                            <div class="footer">
                               <footer class="text-muted">
                                  <div class="container">
                                      <style>
                                          * {
                                              margin: 0;
                                              padding: 0;
                                            }
                                            html,
                                            body {
                                              height: 100%;
                                            }
                                            .wrapper {
                                              position: relative;
                                              min-height: 30%;
                                            }
                                            .content {
                                              padding-bottom: 90px;
                                            }
                                            .footer {
                                              position: absolute;
                                              left: 0;
                                              bottom: 0;
                                              width: 100%;
                                              height: 10px;
                                            }
                                      </style>
                                    <p class="float-right">
                                      <a href="#">На вверх!</a>
                                    </p>
                                    <p>PLAYTI - сайт с множеством паков ютуберов, PSD оформлений, а так-же дизайнеров и программистов</p>
                                    <p>В первые у нас? <a href="https://t.me/play_ti">Присоединяйтесь к нашему Telegram каналу </a>там есть оповещения о новинках на сайте.</p>
                                  </div>
                               </footer>
                            </div>
                        </div>
                    </div>
</body>
</html>


Here is the psd page and it has a different code, but the Index code is displayed
<!DOCTYPE html>
<html lang="ru" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>PLAYTI - PSD макеты</title>
  </head>
  <body>

  </body>
</html>


Here are the views
from django.shortcuts import render

def index(request):
    return render(request, 'main/index.html');

def psd(request):
    return render(request, 'main/psd.html');

def puk(request):
    return render(request, 'main/pak.html');

def php(request):
    return render(request, 'main/php.html');

def sale(request):
    return render(request, 'main/sale.html');


This is the ursl of the app.
from django.urls import path
from . import views

urlpatterns = {
    path('', views.index),
    path('psd', views.psd),
    path('puk', views.puk),
    path('php', views.php),
    path('sale', views.sale),

}


This is the site urls
from django.contrib import admin
from django.urls import path, include

urlpatterns = {
    path('admin/', admin.site.urls),
    path('', include('main.urls')),
    path('psd', include('main.urls')),
    path('puk', include('main.urls')),
    path('php', include('main.urls')),
    path('sale', include('main.urls')),
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-11-29
@sergey-gornostaev

Because you haven't read the documentation and don't understand how urlpatterns work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question