В настоящее время я использую как это, но ничего не работает .... Я пытался проверить оба класса, но ничего не работает (UserPage и UserPageCarousel), но ничего не работает.
class UserPageCarousel(Orderable):
def get_context_data(self, request):
context = super(UserPageCarousel, self).get_context(request)
products = UserPageCarousel.objects.all()
print(products)
n = len(products)
nslides = n // 4 + ceil((n / 4) - (n // 4))
context['no_of_slides'] = nslides
context['range'] = range(1, nslides)
context['product'] = products
return context
page = ParentalKey("user.UserPage", related_name="carousel_videos", null=True)
carousel_video = models.ForeignKey(
"wagtailvideos.Video",
related_name="+",
null=True,
blank=False,
on_delete=models.SET_NULL)
panels = [
VideoChooserPanel('carousel_video')
]
class UserPage(Page):
content_panels = Page.content_panels + [
MultiFieldPanel([
InlinePanel('carousel_videos', label="Video")
], heading="Add Videos To List")
]
class Meta:
verbose_name = "User Page"
verbose_name_plural = "User Pages"
и вот мой шаблон (путь - user / user_page.html) Код: -
<p> Welcome Hi </p>
{% if request.user.is_authenticated %}
{{ user.username }}
{% endif %}
{% for loop_cycle in self.carousel_videos.all %}
<p>{{ loop_cycle.carousel_video.url }}</p>
{% endfor %}
{% for i in range %}
<p> {{ i }}</p>
{% endfor %}
Весь код шаблона работает, но я в диапазоне ничего не дает Означает мое получениеконтекст не работает ни в коем случае
Текущий вывод: -
Welcome Hi Hahaha
puneet
/media/original_videos/horse_rolling_farm_animal_equine_1067.mp4
/media/original_videos/horse_rolling_farm_animal_equine_1067_ME9ybb0.mp4
/media/original_videos/horse_rolling_farm_animal_equine_1067_Ix4pCIa.mp4
/media/original_videos/Horses_2.mp4
/media/original_videos/horse_rolling_farm_animal_equine_1067_rhDf82J.mp4