使用 Javascript 出现 302 和 404 错误

发布于 2024-08-04 02:15:00 字数 337 浏览 3 评论 0原文

我正在尝试在我的 Django 站点中运行 WMDEditor。我已将 WMD 文件安装在网站根目录的 /static/js/wmd.wmd.js 目录中。

但是,当页面得到服务时,我得到:

INFO     2009-09-08 11:00:48,217 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js HTTP/1.1" 302 -
INFO     2009-09-08 11:00:48,733 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js/ HTTP/1.1" 404 -

I am trying to run WMDEditor in my Django site. I have installed WMD files in a directory called /static/js/wmd.wmd.js of the root of my website.

However when the page get served I get:

INFO     2009-09-08 11:00:48,217 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js HTTP/1.1" 302 -
INFO     2009-09-08 11:00:48,733 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js/ HTTP/1.1" 404 -

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

新一帅帅 2024-08-11 02:15:00

我有一些类似的问题。确保您还添加到 app.yaml 文件中

handlers:
- url: /static
  static_dir: static

I had some similar problems. Make sure you also add to your app.yaml file

handlers:
- url: /static
  static_dir: static
驱逐舰岛风号 2024-08-11 02:15:00

发生的情况是重定向,因为 Django 认为您的 URL 应该以斜杠 (/) 结尾,但即使末尾有斜杠,该 url 显然也不正确。

将其添加到根 urls.py 文件中,并确保 settings.MEDIA_ROOT 是静态目录的绝对路径:

urlpatterns += patterns('',
    (r'^static/(?P<path>.*)

另请注意,在生产设置中,Django 不应提供静态文件。

, 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )

另请注意,在生产设置中,Django 不应提供静态文件。

What is happening is a redirect, because Django thinks your URLs should end with a slash (/), but even with a slash at the end, the url is obviously incorrect.

Add this to your root urls.py file and make sure that settings.MEDIA_ROOT is an absolute path to your static directory:

urlpatterns += patterns('',
    (r'^static/(?P<path>.*)

Also note that in a production setting static files should not be served by Django.

, 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), )

Also note that in a production setting static files should not be served by Django.

旧故 2024-08-11 02:15:00

django 开发服务器自动提供管理静态文件。

但是,我不知道它对您自己添加的静态文件的行为如何。我已经让 WMDEditor 在生产环境中工作,但不在开发环境中工作。

本文概述了如何以一种黑客的方式在dev 环境来提供静态文件。但是,您需要在生产环境中设置别名。

The django dev server serves admin static files automagically.

However, I don't know how it behaves with static files you yourself add. I've gotten the WMDEditor working in a production enviroment, but not a dev one.

This article outlines how to get a hackish way to work in the dev enviroment to serve static files. You'll want to set up an alias in the production enviroment however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文