W
W
Werdjill2020-05-03 20:10:02
Django
Werdjill, 2020-05-03 20:10:02

Django does not show anything when starting the debug server, there is no error, how to solve it?

Good evening, when running the Django debug server, it shows nothing but Bootstrap, no errors were found.

Code Views
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from .models import *

def posts_wall(request):
    object_list = Post.objects.all()
    paginator = Paginator(object_list, 5)
    page = request.GET.get('page')
    try:
        posts = paginator.page(page)
    except PageNotAnInteger:
        posts = paginator.page(1)
    except EmptyPage:
        posts = paginator.page(paginator.num_pages)
    return render(request, 'blog/post/paginators.html', {'page' : page, 'posts' : posts})
def post_detail(request, year, month, day, post):
    post = get_object_or_404(Post, slug = post, status = 'published', published_year = year,
        published_month = month, published_day = day)
    return render(request, 'blog/post/detail.html', {'post' : post})


Code templates/blog/post/pagination.py
{% extends "blog/base.html" %}
<div class="pagination">
    <span class="step-links">
        {% if page.has_previous %}
            <a href="?page={{page.previous_page_number}}">Previous</a>
        {% endif %}
        <span class="current">
            Page {{ page.number }} of {{ page.paginator.num_pages }}.
        {% if page.has_next %}
            <a href="?page={{ page.next_page_number }}">Next</a>
        {% endif %}
    </span>
</div>


code list
{% extends "blog/base.html" %}
{% block title %}My Blog{% endblock %}
{% block content %}
    <h1 align = 'center'>My Blog</h1>
{% for post in posts %}
<h2>
    <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
</h2>
<p class="date">Published {{ post.publish }} by {{ post.author }}</p>
{{ post.body|truncatewords:30|linebreaks }}
{% endfor %}
    {% include "pagination.html" with page=posts %}
{% endblock %}

Thanks in advance for possible answers ;)
5eaef9a0f2d5d279120838.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
Werdjill, 2020-05-03
@Werdjill

There are objects in the database

A
alternativshik, 2020-05-04
@alternativshik

{% include "pagination.html" with page=posts %}
and above "templates/blog/post/pagination.py" of course it won't output anything

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question