Я пытаюсь включить шаблон (заголовок. html) из другого представления в другой шаблон (индекс. html), который имеет другое представление, но, похоже, ничего не отображается в разделе заголовка при загрузке страницы
вот где views.py
from django.contrib.auth import get_user_model
from django.views.generic import TemplateView, ListView
from baykay.models import Projects, Profile
User = get_user_model()
class HomeView(TemplateView):
template_name = 'portfolio/index.html'
class Header(ListView):
template_name = 'portfolio/header.html'
model = Profile
context_object_name = 'header'
вот заголовок. html
<div class="container clearfix">
{% for profile in object_list %}
{% if profile.image %}
<img class="profile-image img-fluid float-left avatar-img" src="{{ profile.image.url }}" alt="young-baykay"/>
{% endif %}
<div class="profile-content float-left">
<h1 class="name">{{ profile.user.get_full_name|title }}</h1>
<h2 class="desc">{{ profile.profession|title }}</h2>
</div><!--//profile-->
{% endfor %}
<a class="btn btn-cta-primary float-right" href="#" target="_blank"><i class="fas fa-paper-plane"></i> Contact</a>
</div>
вот индекс. html
<!DOCTYPE html>
<html lang="en">
<head>
{% include 'portfolio/styles.html' %}
</head>
<body>
<header class="header">
{% include 'portfolio/header.html' with profile=object_list only %}
</header><!--//header-->
{% include 'portfolio/footer.html' %}
{% include 'portfolio/javascript.html' %}
</body>
</html>
вот модель.py
from django.contrib.auth import get_user_model
from django.db import models
User = get_user_model()
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
image = models.ImageField(upload_to='profile_pic', blank=True, null=True)
profession = models.CharField(max_length=50, blank=True, null=True)
bio = models.TextField(blank=True, null=True)
city = models.CharField(max_length=10, blank=True)
country = models.CharField(max_length=10, blank=True)
website = models.URLField(blank=True, null=True)
def __str__(self):
return ""
def get_location(self):
return '{}, {}'.format(self.city, self.country)
пожалуйста, если вы знаете лучший способ go, то сообщите мне