Помогите советом, пожалуйста. Когда я go попадаю на одну из страниц, отображается ее код, в инспекторе я вижу, что весь код взят в теге <pre>
, хотя в коде этого тега нет. Как это преодолеть? Заранее спасибо!
панель навигации:
python
<li {% if 'about' in request.path %} class="active" {% else %} {% endif %}><a href="{% url 'about' %}" class="nav-link">About</a></li>
Основной URL:
urlpatterns = [
path('', include("pages.urls")),
...
URL-адреса страниц приложения:
urlpatterns = [
path('', views.index, name="index"),
path('about', views.about, name = "about"),
...
Я здесь первый, не знаю, возможно страницу с кодом нужно разместить отдельно
О странице:
{% extends 'base.html' %}
{% block title %} About {% endblock %}
{% load static %}
{% block content %}
{% include "partials/_header_internal.html" %}
<div class="site-section">
<div class="container">
<div class="row">
<div class="col-lg-6 mb-5 mb-lg-0 order-lg-2">
<img src="{% static 'images/hero_2.jpg' %}" alt="Image" class="img-fluid">
</div>
<div class="col-lg-4 mr-auto">
<h2>Car Company</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit suscipit, repudiandae similique
accusantium eius nulla quam laudantium sequi.</p>
<p>Debitis voluptates corporis saepe molestias tenetur ab quae, quo earum commodi, laborum dolore, fuga
aliquid delectus cum ipsa?</p>
</div>
</div>
</div>
</div>
<div class="site-section bg-light">
<div class="container">
<div class="row justify-content-center text-center mb-5 section-2-title">
<div class="col-md-6">
<span class="text-primary">Our Team</span>
<h2 class="mb-4">Meet Our Team</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Reiciendis provident eius ratione velit,
voluptas laborum nemo quas ad necessitatibus placeat?</p>
</div>
</div>
<div class="row align-items-stretch">
{% if managers %}
{% for manager in managers %}
<div class="col-lg-4 col-md-6 mb-5">
<div class="post-entry-1 h-100 person-1">
<img src="{{ manager.photo.url }}" alt="Image" class="img-fluid">
<div class="post-entry-1-contents">
<span class="meta">Manager</span>
<h2>{{ manager.name }}</h2>
<p>{{ manager.description }}</p>
</div>
</div>
</div>
{% endfor %}
{% else %}
<div class="col-md-12">
<p>No Managers Aviable</p>
</div>
{% endif %}
</div>
</div>
</div>
<div class="site-section">
<div class="container">
<div class="row">
<div class="col-lg-6 mb-5 mb-lg-0">
<img src="{% static 'images/hero_1.jpg' %}" alt="Image" class="img-fluid">
</div>
<div class="col-lg-4 ml-auto">
<h2>Our History</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit suscipit, repudiandae similique
accusantium eius nulla quam laudantium sequi.</p>
<p>Debitis voluptates corporis saepe molestias tenetur ab quae, quo earum commodi, laborum dolore, fuga
aliquid delectus cum ipsa?</p>
</div>
</div>
</div>
</div>
<div class="container site-section mb-5">
<div class="row justify-content-center text-center">
<div class="col-7 text-center mb-5">
<h2>How it works</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nemo assumenda, dolorum necessitatibus eius
earum voluptates sed!</p>
</div>
</div>
<div class="how-it-works d-flex">
<div class="step">
<span class="number"><span>01</span></span>
<span class="caption">Time & Place</span>
</div>
<div class="step">
<span class="number"><span>02</span></span>
<span class="caption">Car</span>
</div>
<div class="step">
<span class="number"><span>03</span></span>
<span class="caption">Details</span>
</div>
<div class="step">
<span class="number"><span>04</span></span>
<span class="caption">Checkout</span>
</div>
<div class="step">
<span class="number"><span>05</span></span>
<span class="caption">Done</span>
</div>
</div>
</div>
{% endblock %}
База. html:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=DM+Sans:300,400,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href = "{% static 'fonts/icomoon/style.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/bootstrap.min.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/bootstrap-datepicker.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/jquery.fancybox.min.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/owl.carousel.min.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/owl.theme.default.min.css' %}"/>
<link rel="stylesheet" href = "{% static 'fonts/flaticon/font/flaticon.css' %}"/>
<link rel="stylesheet" href = "{% static 'css/aos.css' %}"/>
<!-- main css -->
<link rel="stylesheet" href = "{% static 'css/style.css' %}"/>
<title>{% block title %} {% endblock %}</title>
</head>
<body data-spy="scroll" data-target=".site-navbar-target" data-offset="300">
{% include "partials/_navbar.html" %}
{% block content %} {% endblock %}
{% include "partials/_footer.html" %}
<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/owl.carousel.min.js' %}"></script>
<script src="{% static 'js/jquery.sticky.js' %}"></script>
<script src="{% static 'js/jquery.waypoints.min.js' %}"></script>
<script src="{% static 'js/jquery.animateNumber.min.js' %}"></script>
<script src="{% static 'js/jquery.fancybox.min.js' %}"></script>
<script src="{% static 'js/jquery.easing.1.3.js' %}"></script>
<script src="{% static 'js/bootstrap-datepicker.min.js' %}"></script>
<script src="{% static 'js/aos.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
</body>
</html>
страниц> views.py:
from cars.models import CarsList
from carmanager.models import CarManager
from .cars_Info import vendor_list, models_list, engine_list, transmission_list
from django.core.paginator import Paginator
from contacts.models import Contacts
def index(request):
cars = CarsList.objects.all().filter(is_published=True)
query = CarsList.objects.order_by("vendor")
random_car = CarsList.objects.order_by('?')[0]
orders = Contacts.objects.all().filter(is_published=True)
random_orders = Contacts.objects.filter(is_published=True).order_by('?')[:3]
paginator = Paginator(cars, 3)
page = request.GET.get("page")
paged_cars = paginator.get_page(page)
if "vendor" in request.GET:
vendor = request.GET["vendor"]
if vendor:
query = query.filter(vendor__iexact=vendor)
if "model" in request.GET:
model = request.GET["model"]
if model:
query = query.filter(model__iexact=model)
if "engine" in request.GET:
engine = request.GET["engine"]
if engine:
query = query.filter(engine__iexact=engine)
if "transmission" in request.GET:
transmission = request.GET["transmission"]
if transmission:
query = query.filter(transmission__iexact=transmission)
context = {
"cars_all": cars,
'cars': paged_cars,
"vendor_list": vendor_list,
"models_list": models_list,
"engine_list": engine_list,
"transmission_list": transmission_list,
"search_cars": query,
"request_value": request.GET,
"rnd_car": random_car,
"random_orders": random_orders
}
return render(request, 'pages/index.html', context)
def about(request):
managers = CarManager.objects.all().filter(is_published=True)[:3]
context = {
'managers': managers,
}
data = {'title': "About Us"}
return render(request, 'pages/about.html', context, data)
def services(request):
data = {'title': "Our Services"}
return render(request, 'pages/services.html', data)
def contact(request):
data = {'title': "Contact Us"}
return render(request, 'pages/contact.html', data)
def search(request):
query = CarsList.objects.order_by("vendor")
paginator = Paginator(query, 3)
page = request.GET.get("page")
paged_search_cars = paginator.get_page(page)
if "vendor" in request.GET:
vendor = request.GET["vendor"]
if vendor:
query = query.filter(vendor__iexact=vendor)
if "model" in request.GET:
model = request.GET["model"]
if model:
query = query.filter(model__iexact=model)
if "engine" in request.GET:
engine = request.GET["engine"]
if engine:
query = query.filter(engine__iexact=engine)
if "transmission" in request.GET:
transmission = request.GET["transmission"]
if transmission:
query = query.filter(transmission__iexact=transmission)
context = {
"search_cars": query,
"paged_search_cars": paged_search_cars,
"vendor_list": vendor_list,
"models_list": models_list,
"engine_list": engine_list,
"transmission_list": transmission_list,
"request_value": request.GET
}
return render(request, 'pages/search.html', context)