Reputation: 12098
The error (when running the django runserver command):
ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
I don't really use django static (this is mostly and api server) and I just want django debug to debug and explain
my sql queries. So what I have is:
STATIC_DIRECTORY = '/'
MEDIA_DIRECTORY = '/media/'
STATIC_URL = S3_URL + STATIC_DIRECTORY
MEDIA_URL = S3_URL + MEDIA_DIRECTORY
STATICFILES_STORAGE = 'server.s3utils.StaticRootS3BotoStorage'
DEFAULT_FILE_STORAGE = 'server.s3utils.MediaRootS3BotoStorage'
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
abs_path('staticfiles'),
# ABS_PATH('/static/'), #D either
)oesn't work either
)
EDIT: If I just remove STATICFILES_DIRS
the errors changes:
TypeError at /admin/ Error when calling the metaclass bases function() argument 1 must be code, not str Request Method: GET Request URL: http://localhost:8000/admin/ Django Version: 1.6.2 Exception Type: TypeError Exception Value: Error when calling the metaclass bases function() argument 1 must be code, not str
I also tried as one of the answers suggested to add
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
Doesn't help..
I guess that I'm missing something very simple (but annoying) I'll be glad for help with this.
Upvotes: 3
Views: 2801
Reputation: 632
pip install django-debug-toolbar
check your settings.py file :
INSTALLED_APPS = [
'django.contrib.staticfiles',
'debug_toolbar',
...
MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware",
...
]
...
INTERNAL_IPS = [
"127.0.0.1",
]
...
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
)
urls.py
path("__debug__/", include(debug_toolbar.urls)),
And run this command : python manage.py collectstatic
Upvotes: 0
Reputation: 535
I had encountered the same error when I created custom storage using lambda:
StaticRootS3BotoStorage = lambda: S3Boto3Storage(bucket_name='example-name')
Changing it to class solved the problem:
class StaticRootS3BotoStorage(S3Boto3Storage):
bucket_name='example-name'
Upvotes: 0
Reputation: 141
Django debug toolbar chokes when using S3BotoStorage. I mostly wanted SQL logging, so adding this code to settings.py to disable the StaticFilesPanel was a workaround for me:
DEBUG_TOOLBAR_PANELS = [
'debug_toolbar.panels.versions.VersionsPanel',
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.settings.SettingsPanel',
'debug_toolbar.panels.headers.HeadersPanel',
'debug_toolbar.panels.request.RequestPanel',
'debug_toolbar.panels.sql.SQLPanel',
# 'debug_toolbar.panels.staticfiles.StaticFilesPanel',
'debug_toolbar.panels.templates.TemplatesPanel',
'debug_toolbar.panels.cache.CachePanel',
'debug_toolbar.panels.signals.SignalsPanel',
'debug_toolbar.panels.logging.LoggingPanel',
'debug_toolbar.panels.redirects.RedirectsPanel',
]
Upvotes: 9
Reputation: 680
This django-debug-toolbar explicit-setup Says something about:
from django.conf import settings
from django.conf.urls import include, patterns, url
if settings.DEBUG:
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),
)
Have you tried?
Upvotes: 0