Reputation: 9392
I am using Django-pipeline for asset minification and compression but there seems to be an error when I try to run
./manage collectstatic
I get the following error..
django.core.exceptions.SuspiciousFileOperation: Attempted access to '/home/darwesh/projects/first/api/static/js/app/check.js' denied.
Here is my settings.py file
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'api/static'),
)
STATIC_ROOT = os.path.join(BASE_DIR, 'api/static_final/')
STATIC_URL = '/static/'
STATIC_PATH = os.path.join(BASE_DIR, 'api/static/')
# pipeline settings
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_JS = {
'check': {
'source_filenames' : (
STATIC_PATH + 'js/app/controllers.js',
),
'output_filename': STATIC_PATH + 'js/app/check.js',
},
}
Here is my file structure
project
|__api
|__static
|__js
|__app
|__ controllers.js
|__ check.js # expected output file
Upvotes: 3
Views: 811
Reputation: 10850
Another reason this can happen is if you're missing a comma in the source_filenames
tuple with one filename, which makes it a string:
With missing comma, ('js/app/controllers.js')
is a string and throws SuspiciousFileOperation
:
PIPELINE_JS = {
'check': {
'source_filenames' : (
'js/app/controllers.js'
),
'output_filename': 'js/app/check.js',
},
}
Fixed:
PIPELINE_JS = {
'check': {
'source_filenames' : (
'js/app/controllers.js',
),
'output_filename': 'js/app/check.js',
},
}
Upvotes: 1
Reputation: 1758
Remove
STATIC_PATH +
from both source_filenames
and output_filename
I suspect the reason you added that was due to ./manage.py collectstatic
not producing an output in your js/app
directory (thats what caused my confusion). To fix this in settings.py set
PIPELINE_ENABLED = True # pipeline > 1.3
#PIPELINE = True # pipeline < 1.3
STATIC_ROOT = os.path.join(BASE_DIR, 'project/static') # this should also be set
run
./manage.py collectstatic
you should see your generated output_filename
Upvotes: 3