为什么我的静态文件不能提供? 或者只有其中一些我说不出来。 我几乎尝试过所有事情。 我不知道问题出在哪里。 我需要支持让我的静态文件在开发和生产过程中工作。 请先帮助我开发
我试图让我的静态文件工作,我得到这个错误
Django version 1.4.3, using settings 'menu.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [10/Mar/2013 15:12:37] "GET / HTTP/1.1" 200 1868 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/screen.css HTTP/1.1" 500 59 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/print.css HTTP/1.1" 500 59这是我的settings.py
if socket.gethostname() == 'Pangolin': #Brian's Development Laptop DEBUG = TEMPLATE_DEBUG = True TEMPLATE_DIRS = ('/home/talisman/projects/menu/templates',) SQL_LITE_NAME = '/home/talisman/projects/menu/db4.db' STATIC_ROOT = '/home/talisman/projects/menu/static/' 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. '/home/talisman/projects/menu/staticfiles/', )How come my static files don't serve? or only some of them I can't tell. I have tried just about everything. and I don't know where the problem is. I need support for getting my staticfiles to work during development and production. but help me with development first please
I am trying to get my staticfiles to work, and i get this error
Django version 1.4.3, using settings 'menu.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [10/Mar/2013 15:12:37] "GET / HTTP/1.1" 200 1868 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/screen.css HTTP/1.1" 500 59 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/print.css HTTP/1.1" 500 59this is my settings.py
if socket.gethostname() == 'Pangolin': #Brian's Development Laptop DEBUG = TEMPLATE_DEBUG = True TEMPLATE_DIRS = ('/home/talisman/projects/menu/templates',) SQL_LITE_NAME = '/home/talisman/projects/menu/db4.db' STATIC_ROOT = '/home/talisman/projects/menu/static/' 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. '/home/talisman/projects/menu/staticfiles/', )最满意答案
您的设置中可能存在配置错误的静态文件?
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )确保你有上下文处理器:
TEMPLATE_CONTEXT_PROCESSORS = [ ... 'django.core.context_processors.static', ... ]也不要使用那样的路径,用于提供绝对路径......
from os.path import join, dirname, normpath LOCAL_PATH = normpath(join(dirname(__file__), '..'))然后你可以做...
# Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', )=========
这是我如何设置我的一个例子
MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = '/uploaded/' STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )在我安装的应用程序中,我确保我有
'django.contrib.staticfiles',You have misconfigured staticfiles in your settings maybe?
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )make sure you have the context processor:
TEMPLATE_CONTEXT_PROCESSORS = [ ... 'django.core.context_processors.static', ... ]Also don't use paths like that, used to provide absolute paths...
from os.path import join, dirname, normpath LOCAL_PATH = normpath(join(dirname(__file__), '..'))then you can do...
# Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', )=========
here is an example of how I set mine up
MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = '/uploaded/' STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )In my installed apps I make sure I have
'django.contrib.staticfiles',django staticfiles错误(django staticfiles error)为什么我的静态文件不能提供? 或者只有其中一些我说不出来。 我几乎尝试过所有事情。 我不知道问题出在哪里。 我需要支持让我的静态文件在开发和生产过程中工作。 请先帮助我开发
我试图让我的静态文件工作,我得到这个错误
Django version 1.4.3, using settings 'menu.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [10/Mar/2013 15:12:37] "GET / HTTP/1.1" 200 1868 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/screen.css HTTP/1.1" 500 59 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/print.css HTTP/1.1" 500 59这是我的settings.py
if socket.gethostname() == 'Pangolin': #Brian's Development Laptop DEBUG = TEMPLATE_DEBUG = True TEMPLATE_DIRS = ('/home/talisman/projects/menu/templates',) SQL_LITE_NAME = '/home/talisman/projects/menu/db4.db' STATIC_ROOT = '/home/talisman/projects/menu/static/' 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. '/home/talisman/projects/menu/staticfiles/', )How come my static files don't serve? or only some of them I can't tell. I have tried just about everything. and I don't know where the problem is. I need support for getting my staticfiles to work during development and production. but help me with development first please
I am trying to get my staticfiles to work, and i get this error
Django version 1.4.3, using settings 'menu.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [10/Mar/2013 15:12:37] "GET / HTTP/1.1" 200 1868 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/screen.css HTTP/1.1" 500 59 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 68, in __call__ start_response) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 57, in get_response return self.serve(request) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/handlers.py", line 50, in serve return serve(request, self.file_path(request.path), insecure=True) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/views.py", line 36, in serve absolute_path = finders.find(normalized_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 238, in find for finder in get_finders(): File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 256, in get_finders yield get_finder(finder_path) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/Django-1.4.3-py2.7.egg/django/utils/functional.py", line 27, in wrapper result = func(*args) File "/home/talisman/virt_env/menu/local/lib/python2.7/site-packages/staticfiles/finders.py", line 277, in _get_finder (Finder, BaseFinder)) ImproperlyConfigured: Finder "<class 'django.contrib.staticfiles.finders.FileSystemFinder'>" is not a subclass of "<class 'staticfiles.finders.BaseFinder'>" [10/Mar/2013 15:12:37] "GET /static/css/print.css HTTP/1.1" 500 59this is my settings.py
if socket.gethostname() == 'Pangolin': #Brian's Development Laptop DEBUG = TEMPLATE_DEBUG = True TEMPLATE_DIRS = ('/home/talisman/projects/menu/templates',) SQL_LITE_NAME = '/home/talisman/projects/menu/db4.db' STATIC_ROOT = '/home/talisman/projects/menu/static/' 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. '/home/talisman/projects/menu/staticfiles/', )最满意答案
您的设置中可能存在配置错误的静态文件?
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )确保你有上下文处理器:
TEMPLATE_CONTEXT_PROCESSORS = [ ... 'django.core.context_processors.static', ... ]也不要使用那样的路径,用于提供绝对路径......
from os.path import join, dirname, normpath LOCAL_PATH = normpath(join(dirname(__file__), '..'))然后你可以做...
# Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', )=========
这是我如何设置我的一个例子
MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = '/uploaded/' STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )在我安装的应用程序中,我确保我有
'django.contrib.staticfiles',You have misconfigured staticfiles in your settings maybe?
STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )make sure you have the context processor:
TEMPLATE_CONTEXT_PROCESSORS = [ ... 'django.core.context_processors.static', ... ]Also don't use paths like that, used to provide absolute paths...
from os.path import join, dirname, normpath LOCAL_PATH = normpath(join(dirname(__file__), '..'))then you can do...
# Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', )=========
here is an example of how I set mine up
MEDIA_ROOT = '' MEDIA_URL = '' STATIC_ROOT = '/uploaded/' STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( LOCAL_PATH + '/public/common/', ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # 'django.contrib.staticfiles.finders.DefaultStorageFinder', )In my installed apps I make sure I have
'django.contrib.staticfiles',
发布评论