0

I am using Django 1.8.2 with django-pipeline 1.5.1 and Python 3.4

I followed the installation instructions provided by the authors of this tool. On my local machine with the provided development server, everything works fine. But when I try to deploy it on the production server running Apache2 with mod_wsgi4.4.13, I get this error:

SyntaxError at /
invalid syntax (_base.py, line 355)

Error during template rendering

In template /var/www/django/templates/base.html, error at line 13

invalid syntax

12      {% load pipeline %}
13            
          {% stylesheet 'vendor' %}

14      {% stylesheet 'master' %}
15      {% javascript 'vendor' %}
16      {% javascript 'master' %}

Obviously, Apache does not know what to do with the keyword stylesheet. Have to say, that the site was previously running great. But with django-pipeline I get this error.

My pipeline configuration looks like this:

settings.py

DEBUG = True

INSTALLED_APPS = (
    'pipeline',
    ...
)

MIDDLEWARE_CLASSES = (
    'pipeline.middleware.MinifyHTMLMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)

PIPELINE_COMPILERS = (
  'pipeline.compilers.sass.SASSCompiler',
)

PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'

PIPELINE_CSS = {
  'master': {
    'source_filenames': (
      'css/*.sass',
    ),
    'output_filename': 'compressed/master.css',
    'extra_context': {
      'media': 'screen, projection',
    },
  },
  'vendor': {
    'source_filenames': (
      'assets/bootstrap/css/bootstrap.min.css',
      'assets/bootstrap/css/bootstrap-theme.min.css',
      'assets/bootswatch/bootswatch.min.css',
    ),
    'output_filename': 'compressed/vendor.css'
  }
}

PIPELINE_JS = {
  'master': {
    'source_filenames': (
      'js/*.js',
    ),
    'output_filename': 'compressed/master.js'
  },
  'vendor': {
    'source_filenames': (
      'assets/jquery/jquery.min.js',
      'assets/bootstrap/js/bootstrap.min.js',
    ),
    'output_filename': 'compressed/vendor.js'
  }
}

My problem is, that I am convinced to have django-pipeline properly installed and configured, but on my production server I get this error.

Compressing and serving the css and js files works properly on the local maschine. Therefore django-pipeline cannot be heavily misconfigured.

Production Server

  • Ubuntu 14.04
  • Latest Apache 2.4.7
  • Python 3.4
  • Django and all apps installed in a Virtualenv
  • mod_wsgi 4.4.13

Excerpt from Virtualhost

WSGIDaemonProcess django python-path=/var/www/django:/usr/local/share/virtualenvs/django/lib/python3.4/site-packages
WSGIProcessGroup django
WSGIScriptAlias /django /var/www/django/core/wsgi.py
WSGISocketPrefix /var/run/apache2/wsgi

Do you have any ideas how to solve this issue? Thank you!

n2o
  • 6,175
  • 3
  • 28
  • 46
  • Do you use a virtualenv on your production machine? And did you told Apache to use it? – 301_Moved_Permanently Jul 10 '15 at 09:22
  • Yes, I am using a virtualenv for it and configured it in my VirtualHost. Since Django is working, the path should not be wrong. – n2o Jul 10 '15 at 09:26
  • Are the source_filenames meant to be file system paths. Unless the package knows how to resolve them relative to some special directory, you will need to construct them as absolute paths as the current working directory for Apache will generally be '/' and not in your project. If this is the issue, since you are using daemon mode, you could also set the 'home' option to WSGIDaemonProcess to be the directory where you project is. – Graham Dumpleton Jul 10 '15 at 10:26
  • Thanks for this advice. I will try to this later and tell you what happened – n2o Jul 10 '15 at 10:55
  • Graham, I wonder a bit about your suggestion, because it appears, that Django does simply not know what to do with the template tags. If it was a problem in WSGI, i'd expect to get a File not Found error, but the site itself should compile and should mostly be displayed – n2o Jul 10 '15 at 12:22
  • Because it does not translate the tag to `` or similar. – n2o Jul 10 '15 at 12:43
  • Did you find the root cause of the problem ? – Thierry J. Oct 26 '17 at 13:54
  • Nope, have no idea and I am no longer using Django... – n2o Oct 26 '17 at 15:23

0 Answers0