无法设置Python Django LRS。找不到文件

2024-05-31 15:57:37 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

# 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.
)

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

在克隆git时,我设置了LRS,顺便说一句,它启动了,但是所有CSS都坏了。我查看了domspector,其中CSS文件的链接如下-

^{pr2}$

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

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.

我的网址.py看起来-

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))

显然,我并没有在网址.py指出了错误。那么我应该把CSS,JS文件放在哪里来修复坏掉的CSS,并为此创建一个默认的主页呢?我也尝试过从wordpress发送tin can语句,但我无法在我的服务器上获取这些语句。谁能告诉我如何在ubuntu上安装一个合适的adlrs吗。在

PS-不要告诉我阅读文档,因为我已经做了十几次了。告诉我我在执行文档时哪里错了。在


Tags: 文件thetodjangoincomhttpurl
1条回答
网友
1楼 · 发布于 2024-05-31 15:57:37

听起来你让LRS和古尼康一起跑。gunicorn本身不提供JS和CSS之类的静态文件。我发现了另一个SO页面,讨论使用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,它被配置为提供静态文件。我们在https://github.com/adlnet/ADL_LRS/wiki/Using-Nginx-for-Production上有一些关于它的初始设置

相关问题 更多 >