Reputation: 145
I am using django-pipeline for minifying js & versioning of js and css. I am very well aware of Debug=False and allow_hosts=['*'] so that's not the case here. The strange issue is, I am getting 500 server error in 2 of the pages out of 8 pages. The pages are almost same in terms of css and js being used (couple of js/css are here n there but that doesn't seem an issue to me). The 2 of the pages where I am getting 500 server error, are using google maps but even if I remove google maps call, the issue remains the same. settings.py file contains this:
DEBUG = False
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ['*']
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
PIPELINE_CSS = {
'style': {
'source_filenames': (
'css/style.css',
),
'output_filename': 'css/style.min.css',
}
}
PIPELINE_JS = {
'jquery-util': {
'source_filenames': (
'js/jquery.min.js',
'js/mousewheel.js',
'js/jquery-ui-1.9.2.custom.min.js',
'js/jquery-ui-1.9.2.custom-datepicker.min.js',
'js/datepickr.js',
'js/mscrollbar.min.js',
'js/jqtransform.js',
'js/dropdownchecklist.js',
'js/tooltipster.min.js',
'js/jquery.colorbox-min.js',
'js/nouislider.min.js',
'js/unslider.js',
'js/flexslider.js',
'js/base64.min.js',
'js/intro.js',
),
'output_filename': 'js/jquery-util.min.js',
},
'map-util': {
'source_filenames': (
'js/epolys.js',
'js/arc.js',
'js/arrow.js',
'js/map.js',
),
'output_filename': 'js/map-util.min.js',
},
'common-fb': {
'source_filenames': (
'js/common.js',
'js/fb.js',
),
'output_filename': 'js/common-fb.min.js',
},
'home': {
'source_filenames': (
'js/home.js',
),
'output_filename': 'js/home.min.js',
},
'results': {
'source_filenames': (
'js/results.js',
),
'output_filename': 'js/results.min.js',
},
'planning': {
'source_filenames': (
'js/planning.js',
),
'output_filename': 'js/planning.min.js',
},
'account': {
'source_filenames': (
'js/account.js',
),
'output_filename': 'js/account.min.js',
}
}
PIPELINE_DISABLE_WRAPPER = True
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
PIPELINE_YUGLIFY_BINARY = '/usr/local/bin/yuglify'
PIPELINE_YUI_BINARY = 'yui-compressor'
I have spent more than 4 hours in debugging but no help so far. Could anybody please tell me what could be the probable issue here.
P.S. I have added {% load compressed %} to all the templates so this is also not an issue.
Upvotes: 1
Views: 447
Reputation: 145
The strange issue has a strange solution.
After banging head with the wall for so many hours I am able to find the cause and the solution but reason is not clear to me in an absolute way.
When I removed content inside "body" tag completely I didn't get 500 error so I started adding content in small small pieces. What I found is that when there is a comment section in the code, it produces 500 error but after adding few more lines of code having comments was not causing the issue. So I started playing with the comment section and I found out the cause:
<!-- <div class="abc">
<img class="bcd" src="{% static 'images/title.jpg' %}">
<h2 class="xyz">Title</h2>
</div> -->
The above piece of code will cause the 500 error due to
{% static 'images/title.jpg' %}
and if this is removed from the comment, 500 error goes away. This seems a bug with django/django-pipeline.
And strange fact is
<!-- <script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script> -->
doesn't cause 500 error.
If anybody is aware of the reasoning, let me know.
Later on I figured out that this was due to the missing file. When debug is set to True, the static template tag simply puts the static-root path but when debug is set to False, pipeline tries to replace a versioning(with hash added) file of an unavailable file causing the issue. So we have to make sure that all the static template tags have valid file paths in production (debug=False).
Upvotes: 3