将站点迁移到 Django 后,由于将协议更改为 HTTPS,通过 django-embed-video 添加的视频不再显示在 VPS 上。
我试图按照关于此事的说明中所说的去做,但没有任何好事发生:
<div class="row">
{% for my_video in addvideo_list %}
<div class="video">
{% video my_video query="rel=0&wmode=transparent" is_secure=True as my_video %}
{{ my_video.url }} # Получаем строку https://www.youtube.com/embed/8e7kiXsLvbg?rel=0&wmode=transparent
{% video my_video 'small' %} # Все равно нет HTTPS <iframe width="480" height="360" src="http://www.youtube.com/embed/1cCLguVQsMU?wmode=opaque" loading="lazy" frameborder="0" allowfullscreen></iframe>
{% endvideo %}
</div>
{% endfor %}
</div>
请告诉我如何解决这个问题?
意见
class AddVideoListView(ListView):
request.scheme = 'https'
model = AddVideo
queryset = AddVideo.objects.exclude(published=False).order_by('?')
paginate_by = 21
看起来 is_secure 不再用作参数。
相反,变量是从这里拖出来的
HttpRequest.is_secure()
https://docs.djangoproject.com/en/3.2/ref/request-response/#django.http.HttpRequest.is_secure
部署到 nginx添加
拐杖怎么会卡在风景里