Answer the question
In order to leave comments, you need to log in
CANNOT output 2 ForeignKeys?
I want to display ForeignKey from the model
class MangaChapters(models.Model):
name = models.CharField("Название", max_length=100)
ChaptersNumber = models.PositiveSmallIntegerField("Глава", default=0)
tom = models.ForeignKey(MangaToms, verbose_name="Том", on_delete=models.CASCADE)
def __str__(self):
return self.name
class Meta:
verbose_name = 'Глава'
verbose_name_plural = 'Главы'
class MangaToms(models.Model):
name = models.CharField("Название", max_length=100)
TomsNumber = models.PositiveSmallIntegerField("Глава", default=0)
Manga = models.ForeignKey(MangaV, verbose_name="Манга", on_delete=models.CASCADE)
def __str__(self):
return self.name
class Meta:
verbose_name = 'Том'
verbose_name_plural = 'Том'
def osamu(request, slug):
manga = MangaV.objects.get(url=slug)
context = {
'pr': manga
}
return render(request, 'haikyuu/Manga-Full.html', locals())
<div class="col-md-6">
<button class="accordion">Показать главы</button>
<div class="panel">
<ul class="tom">
{% for TomsNumber in manga.mangatoms_set.all %}
<h2 class="chapter-number">Глава {{ TomsNumber.TomsNumber }}</h2>
{% endfor %}
Вот она не выводится>
{% for MangaChapters in mangaG.mangachapters_set.all %}
<li class="chapter">
<a href="">{{ name.name }}</a>
</li>
{% endfor %}
</ul>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question