Answer the question
In order to leave comments, you need to log in
Why is the data not coming to the template?
Can you please tell me why the context is not passed to the template?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ article.title }}</title>
</head>
<h1>{{ article.title }}</h1>
<p>
{{ article.text }}
</p>
<p>
{{ article.published_date }}
</p>
{% if user.is_authenticated %}
<a href="{% url 'delete' pk=article.id %}" class="btn btn-primary">Удалить</a>
<a href="{% url 'edit' pk=article.id %}" class="btn btn-primary">Изменить</a>
{% endif %}
</body>
</html>
path('article/<int:pk>', views.view_article, name='article'),
def view_article(request, pk):
article = Article.objects.filter(id=pk)
return render(request, 'view_article.html', context={'article': article})
Answer the question
In order to leave comments, you need to log in
You are passing a Queryset to the template. It doesn't have title and other attributes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question