arrow_back Why isn't the Django template rendered?

1 vote
In general, you need to output k in user_profile. In task_list it is displayed successfully, but in user_profile it is not. Views
class TaskList(LoginRequiredMixin, ListView):
model = Task
context_object_name = 'tasks'

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['tasks'] = context['tasks'].filter(user=self.request.user)
context['count'] = context['tasks'].filter(complete=False).count()
context['k'] = context['tasks'].filter(complete=True).count()

search_input = self.request.GET.get('search-area') or ''
if search_input:
context['tasks'] = context['tasks'].filter(title__icontains=search_input)
context['search_input'] = search_input

return context
{% extends 'base/main.html' %}
{% load static %}
{% block content %}

<div class="header-bar">

<a href="{% url 'tasks' %}">&#8592; Back</a>


<div class="card-body">
{% if user.profile.profile_pic %}
<img src="{{ profile.profile_pic.url }}" height=100 width=100><br><br>
{% else %}
<img src="{% static 'base\images\profile\user.png' %}" height=100 width=100><br><br>
{% endif %}
<p><strong>Username:</strong> {{ page_user }}</p><br><br>
<p><strong>Bio:</strong> {{ }}</p><br><br>
<p><strong>Twitter:</strong> {{ profile.twitter }}</p><br><br>
<p><strong>Instagram:</strong> {{ profile.instagram }}</p><br><br>
<p><strong>Facebook:</strong> {{ profile.facebook }}</p><br><br>
{% if == %}
<a href="{% url 'edit_user_profile' %}"><button class="button">Edit</button></a>
{% endif %}


{% endblock content %}

{% extends 'base/main.html' %}

{% block content %}

<div class="header-bar">
<script language="javascript" type="text/javascript">
var d = new Date();
var day=new Array("Sunday","Monday","Tuesday",
var month=new Array("January","February","March","April","May","June",
document.write(day[d.getDay()]+" " +d.getDate()+ " " + month[d.getMonth()]
+ " " + d.getFullYear());
<h1>Hello, <a href="{% url 'edit_profile' %}">{{request.user|title}}</a></h1>
<h3 style="margin:0">You have <i style="color:yellow">{{count}}</i> incomplete and <i style="color:yellow">{{k}}</i> complete tasks</h3>

{% if request.user.is_authenticated %}
<ul class="ddropdownn">
<li class="ddropdownn-top">
<a class="ddropdownn-top" href="#">Menu</a>
<ul class="ddropdownn-inside">
<li><a href="{% url 'top-users' %}">Top</a></li>
<li><a href="{% url 'about' %}">About</a></li>
<li><a href="{% url 'edit_profile' %}">Settings</a></li>
{% if %}
<li><a href="{% url 'user_profile' %}">Profile</a></li>
{% else %}
<li><a href="{% url 'create_user_profile' %}">Profile</a></li>
{% endif %}
<li><a href="{% url 'logout' %}">Logout</a></li>
<li><a href="">Support</a></li>

1 Answer

0 votes
Start by answering the question, where in user_profile.html does k suddenly appear?


Vladislava Ok, wait for comments from normal people, I will read "with my eyes narrow Turkmen.
Dr. Bacon I told you, narcissist.
Vladislava Oh how bad it is, it's not a show, that's why I sent you to teach. It's just the output of a variable that wasn't transferred there. You have to pass in a view that explicitly interacts with this pattern or in a context processor. Curtain.
Dr. Bacon I'm sorry it's not going well for you. According to your logic, he shouldn't be able to output it. But it does. Check out
Vladislava It's hard to guess what's in the unspecified code, the crystal ball froze from the cold. And especially with the stubborn