1

Django 的静态文件让我发疯。我成功地能够从 TEMPLATE_DIRS 中指定的目录加载我的模板,但是当我尝试从 STATICFILES_DIRS 加载我的 css 和 js 文件时它不起作用。

以下是我的 settings.py 文件的相关部分:

MEDIA_ROOT = ''
MEDIA_URL = ''

STATIC_ROOT = ''

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    '/home/jrubins/Documents/crowdcluster/crowdcluster/Design/websiteDesign/website/',
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
)

TEMPLATE_DIRS = (
    '/home/jrubins/Documents/crowdcluster/crowdcluster/Design/websiteDesign/website/',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'items'
)

如果您需要更多信息或发现有问题,请告诉我。提前致谢。

4

2 回答 2

1

看起来我没有在我的 render_to_response() 中添加 RequestContext 。解决了这个问题,应该仔细查看 django 文档。

于 2012-10-18T23:13:17.440 回答
0

我遇到了同样的问题,但我发现这个网站有很多信息可以帮助 http://www.b-list.org/weblog/2006/jun/14/django-tips-template-上下文处理器/

于 2012-10-18T23:13:07.487 回答