我使用Django,静态文件无法加载,错误为:
ImproperlyConfigured: The storage backend of the staticfiles finder <class 'django.contrib.staticfiles.finders.DefaultStorageFinder'> doesn't have a valid location.
以下是视图.py:
def results(request):
metaUrl = ""
if not request.method == 'POST':
print "Not Post!"
else:
metaUrl = request.POST['urls']
cmodel = InfoController()
(firstList, wordList, sizeList) = cmodel.controller(metaUrl)
print "I am at result"
return render( request, 'infoRetriever/results.html', { 'firstList': firstList, 'wordList': wordList, 'sizeList': sizeList})
奇怪的是,当我使用时
return render_to_response('infoRetriever/results.html', { 'firstList': firstList, 'wordList': wordList, 'sizeList': sizeList}, context_instance=RequestContext(request))
为了替换views.py中的最后一句话,静态文件加载正常,但会出现其他问题。有人能帮我吗?非常感谢。
您正在使用DefaultStorageFinder
吗?如果不是在settings.py
中去掉STATICFILES_FINDERS
中的那个。
您需要将MEDIA_ROOT
放入settings.py
中。