G
G
galahard12021-08-09 20:02:20
Django
galahard1, 2021-08-09 20:02:20

Through the include tag I connect the template and information from the database is not displayed, everything works with static files, what's wrong?

I'm just starting to learn django and for sure this problem is insignificant, but I can't figure it out myself

. First time I'm writing here, maybe I don't know what rules, don't water too much)

views.py

def slider1(request):
    slider_list = slider.objects.all()
    return render(request, 'media1/slider.html', {'slider_list': slider_list,
                                                 })


slider.html
{% load static %}
<section class="section background-dark">
    {% for sl in slider_list %}
        <div class="line">
        <div class="carousel-fade-transition owl-carousel carousel-main carousel-nav-white carousel-wide-arrows">

        <div class="item">
            <div class="s-12 center">
                <img src="{{ sl.image.url }}" alt="">
                <div class="carousel-content">
                    <div class="padding-2x">
                        <div class="s-12 m-12 l-8">
                            <p class="text-white text-s-size-20 text-m-size-40 text-l-size-60 margin-bottom-40 text-thin text-line-height-1">
                                {{ sl.title }}</p>
                            <p class="text-white text-size-16 margin-bottom-30">{{ sl.text }}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>{% endfor %}
</section>


I specifically created a separate link to the slider, it works via a direct link, it loads pictures and text from the database. If you display it immediately in the index template with the same function as above and the path to the index template, everything also works on the main one. But I want to display it as a separate application

index.html

{% extends 'base.html' %}
{% load static %}

{% block content %}
{% include 'media1/slider.html' %}
{% endblock %}


base.html
{% load static %}


.......
........
.....

{% block content %}

{% endblock %}
.....

the template is included (visible in changing the background) but the slider itself does not appear, if you write something like hello by hand, it is also drawn in the template, but the slider does not

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2021-08-09
@galahard1

And where do you think the data for the slider in index.html will come from?
Code that renders index.html where?..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question