Django模板html文件找不到WebGL Build和TemplateData文件夹

Sop*_*hie 5 python django webgl

为了练习我的 Django 技能,我想尝试在我的网站上托管一个游戏。该游戏是在 Unity 中制作并使用 WebGL 打包的。

我使用 WebGL 创建的 index.html 作为 Django 模板,并在相关位置创建了 URL 路径和视图。WebGL 创建两个文件夹:Build 和 TemplateData,它们在index.html 中引用。

我尝试将这些文件夹与 html 模板一起放入 Django 文件夹结构的每个级别。

无论我把文件夹放在哪里,结果都是一样的。已发送 GET 命令,但一些文件显示“Not Found: /TemplateData/filename....”

有谁知道如何查看 GET 命令正在查找的位置,或者文件夹应该放在哪里?

谢谢,苏菲

Sop*_*hie 4

经过一番混乱之后,我发现您可以将所有内容都放入 static 文件夹中,然后在 index.html 中引用它,就像在 base.html 中选取 css 文件一样

    {% load static %}
       .....some more code

    <script>
        var gameInstance = UnityLoader.instantiate("gameContainer", "{% static 
       'Build/Juno_WebGL.json' %}", {onProgress: UnityProgress});
    </script>
Run Code Online (Sandbox Code Playgroud)

对 index.html 中文件的每个引用都执行此操作