django_embed_video模块引发错误和“ e e do do do nond”看起来像一个模块路径。

发布于 2025-02-07 12:20:11 字数 1914 浏览 1 评论 0原文

我已经6个小时试图弄清楚为什么不 django_embed_video模块按预期工作。 我遵循文档。创建了一个使用视频播放字段的模型。在template.html中使用。

添加了以下内容:

EMBED_VIDEO_BACKENDS = (
    'embed_video.backends.YoutubeBackend',
)

settings.py

我要实现的只是在模板中查看YouTube视频,但是我一直遇到此错误:

detect_backend(str(backend_or_url))
File "project\venv\lib\site-packages\embed_video\backends.py", line 61, in detect_backend
backend = import_string(backend_name)
File "project\venv\lib\site-packages\django\utils\module_loading.py", line 27, in import_stringraise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: e doesn't look like a module path

template.html

...
{% load static %}
{% load embed_video_tags %}
...
{% for tid, t in tests.items %}
<div class="embed-responsive embed-responsive-16by9"> <!-- Bootstrap responsive layout -->
    {% video t.ytvideo.url %} <!-- iterate tests and get YT video of each test -->
</div>
{% endfor %}

理论:检测后端有错误,但我似乎无法理解!

如果您有一种双方的方法可以在网站中获得嵌入YouTube视频,这将不胜感激。我尝试使用仅从YT网站复制的摘要代码嵌入YT视频,但是关于CORS策略,我在前端面临许多错误。

我安装了Django CORS模块,并允许Origin到所有网站,但仍面临cookie问题以及其他CORS策略不起作用,或者将YT视频被浏览器封锁,以解决cookie跟踪问题。感谢进一步的帮助。提前致谢。

编辑:

现在,页面成功加载,但视频没有出现。

控制台日志:一些cookie滥用了建议的“ samesite”属性

我尝试了以下解决方案,但没有起作用:

CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = 'None'
SESSION_COOKIE_SAMESITE = 'None'

我缺少什么?

I have been 6 hours trying to figure out why doesn't the django_embed_video module work as supposed.
I followed the documentation. Created a model with VideoEmbed Field. Used it in template.html.

Added the following:

EMBED_VIDEO_BACKENDS = (
    'embed_video.backends.YoutubeBackend',
)

to settings.py

All i am trying to achieve is to view a youtube video in my template, but i keep getting this error:

detect_backend(str(backend_or_url))
File "project\venv\lib\site-packages\embed_video\backends.py", line 61, in detect_backend
backend = import_string(backend_name)
File "project\venv\lib\site-packages\django\utils\module_loading.py", line 27, in import_stringraise ImportError("%s doesn't look like a module path" % dotted_path) from err
ImportError: e doesn't look like a module path

template.html

...
{% load static %}
{% load embed_video_tags %}
...
{% for tid, t in tests.items %}
<div class="embed-responsive embed-responsive-16by9"> <!-- Bootstrap responsive layout -->
    {% video t.ytvideo.url %} <!-- iterate tests and get YT video of each test -->
</div>
{% endfor %}

Theory: There is an error in detecting the backend, but I can't seem to get it!

If you have a diifferent way to achieve embedding youtube video in website, it would be appreciated. I have tried embedding yt video with just snippet code copied from yt website, but i faced tons of errors on the front-end regarding the CORS policies.

I installed django CORS module and allowed origin to all websites, yet kept facing cookie issues along with other CORS policies not working, or getting yt video blocked by the browser for cookie tracking issues. Further help is appreciated. Thanks in advance.

EDIT:

Now the page loads successfully but the video doesn't appear.

Console logs: Some cookies are misusing the recommended “SameSite“ attribute

I tried the following solution but didn't work:

CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = 'None'
SESSION_COOKIE_SAMESITE = 'None'

What am i missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文