@Semechka1290

Почему не отображаестся страница Detail?

Не знаю почему не отображается страница, наверное ошибка глупая и я просто не внимателен.

views
from django.views.generic import ListView, DetailView
from .models import Question, Answer

class HomePageListView(ListView):
    template_name = 'home.html'
    model = Question

class QuestionDetail(DetailView):
    template_name = 'detail.html'
    model = Answer
    model = Question


urls
from django.urls import path

from .views import QuestionDetail, HomePageListView

urlpatterns = [
    path('', HomePageListView.as_view(), name='QuestionsList'),
    path('q/<int:pk>/', QuestionDetail.as_view(), name='detail'),
]


models
from django.db import models

class Question(models.Model):
    title = models.CharField(max_length=80)
    text = models.TextField(null=True)

class Answer(models.Model):
    question = models.ForeignKey('Question', on_delete=models.CASCADE, null=True)
    text = models.TextField()


detail.html
{% extends 'base.html' %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        {% block content %}
        {% for question in object_list %}
        <h1>{{ question.title }}</h1>
        <p>{{ question.text }}</p>
        {% endfor %}
        {% for answer in object_list %}
        <p>{{ answer.text }}</p>
        {% endfor %}
        {% endblock content %}
    </div>
</body>
</html>


Ошибок никаких нет, ни в консоли, ни на странице. Она проста пустая
  • Вопрос задан
  • 38 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы