相关疑难解决方法(0)

提供媒体文件,不提供静态文件

我坚持因 常绿 问题,静态文件没有送达.相反,放置在MEDIA_ROOT子树中的文件可以正确地提供MEDIA_URL.

剥离settings.py:

DEBUG = True
STATIC_URL = '/static/'
STATIC_ROOT = '/home/foo/devel/static'
MEDIA_URL = '/media/'
MEDIA_ROOT = '/home/foo/devel/media'
# the following is deprecated but is it seems grappelly requires it
ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/"
STATIC_FILES = ()
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
Run Code Online (Sandbox Code Playgroud)

为了创建我做的项目:

$ cd /home/foo/devel/
$ virtualenv testdrive
$ . bin/activate; pip install django; cd testdrive
$ django-admin.py fbtest
Run Code Online (Sandbox Code Playgroud)

并获得此目录树(剥离):

. <-- /home/foo/devel/
??? bin
??? fbtest
? …
Run Code Online (Sandbox Code Playgroud)

django static-files django-staticfiles

1
推荐指数
1
解决办法
1643
查看次数

标签 统计

django ×1

django-staticfiles ×1

static-files ×1