首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python django LRS无法设置。文件未找到错误

Python django LRS无法设置。文件未找到错误
EN

Stack Overflow用户
提问于 2013-04-10 10:44:28
回答 1查看 903关注 0票数 1

我正在使用ADL LRS设置一个LRS(学习记录存储)系统,供我自己使用。它使用TIN CAN API。我正在使用ubuntu服务器

正如文档所述,对于LRS的设置,我需要安装django和为LRS设置它。adl_lrs文件夹中的ADL_LRS包含django(settings.py)的设置文件。我对django有点陌生,所以我不能完全理解这部分文件的含义-

代码语言:javascript
复制
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = '/var/www/adllrs/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://my-site-name.com/media/"
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

它的意思是- 1. MEDIA_ROOT = '/var/www/adllrs/media/',意思是把像歌曲和视频这样的媒体文件放在这个位置2. STATIC_ROOT = ''是指包含HTML、CSS、js文件的静态目录的路径。

在克隆git时,我设置了LRS,顺便说一下,LRS开始了,但是所有的CSS都中断了。我查看了DOM检查器,其中CSS文件的链接类似于-

代码语言:javascript
复制
http://my-site-name.com:8000/static/admin/css/base.css

当我访问上面的url以查看发生了什么情况时,我得到了下面的HTML输出(与访问主页(即http://my-site-name.com:8000)时相同)-

代码语言:javascript
复制
Page not found (404)
Request Method:     GET
Request URL:    http://my-site-name.com:8000/

    Using the URLconf defined in adl_lrs.urls, Django tried these URL patterns, in this order:

        ^XAPI/
        ^xapi/
        ^admin/

    The current URL, , didn't match any of these.

我的urls.py看起来-

代码语言:javascript
复制
url(r'^XAPI/', include('lrs.urls')),
url(r'^xapi/', include('lrs.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls))

显然,我并没有在urls.py中提到指向错误的主页。那么,我应该将CSS、JS文件放在哪里才能修复已损坏的CSS,并为此创建一个默认主页?我也尝试过发送wordpress的tin can语句,但是我无法在我的服务器上获得语句。有人能告诉我如何在ubuntu上建立一个正确的ADL吗?

PS-不要告诉我读文档,因为我已经做了十几次。告诉我在实现这些文档的过程中我哪里错了。

EN

回答 1

Stack Overflow用户

发布于 2013-12-23 12:49:23

听起来你让LRS带着枪跑了。gunicorn本身并不提供像JS和CSS这样的静态文件。我发现了另外一个关于使用gunicorn提供静态文件的页面:https://stackoverflow.com/a/12801140/1187723

至于LRS,当我在本地开发和测试时,我运行Django的测试服务器,它将提供静态文件。在项目的根目录ADL_LRS中,使用python manage.py runserver启动它。https://docs.djangoproject.com/en/1.4/ref/django-admin/#runserver-port-or-address-port

当我们在https://lrs.adlnet.gov/xapi/上部署LRS时,我们使用nginx,它被配置为服务于静态文件。我们在LRS/wiki/使用-Nginx生产有一些关于它的初步设置

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15923631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档