In the Django project, in the posts application, I have a model:
class Post(models.Model): title = models.CharField(max_length=50) text = models.TextField() date = models.DateTimeField(auto_now_add=True) tags = models.ManyToManyField(Tag) def __str__(self): return self.title` The file views.py spelled:
from django.shortcuts import render from django.views.generic.detail import DetailView from posts.models import Post class PostDetailView(DetailView): model = Post def get_context_data(self, **kwargs): context = super(PostDetailView, self).get_context_data(**kwargs) return context post_detail.html:
{% load static %} {% extends 'base.html' %} {% block title%} <h1>{{object.title}}</h1> {% endblock%} {% block content%} <p>{{object.text}}</p> <p>{{object.date}}</p> {% endblock%} and URLConf: url(r'^index/(?P<pk>\d+)/$', views.PostDetailView.as_view(), name='post_detail')
When I write in the address bar: localhost: 8000 / index / 1, then only the basic template is displayed, but there is no information about the post on the page, what could be the problem?