Django collectstatic fails in CircleCI

python
circle.yml

#1

My build fails during the static file preparation. The exact same setup works fine on both my local and Heroku.

My stack:
Python 2.7.10
Django 1.9

Django settings for STATICFILES_STORAGE: 'pipeline.storage.PipelineCachedStorage'

My circle.yml file:

machine:
  timezone:
    Europe/Istanbul
  python:
    version:
      2.7.10
  environment:
    DATABASE_URL: postgres://ubuntu:@localhost:5432/dbname
    DEBUG: True
    ...
test:
  pre:
    - ./manage.py collectstatic --no-input

The error message and the traceback:

> ./manage.py collectstatic --no-input
> Traceback (most recent call last):
>   File "./manage.py", line 10, in <module>
>     execute_from_command_line(sys.argv)
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
>     utility.execute()
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/core/management/__init__.py", line 327, in execute
>     django.setup()
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
>     apps.populate(settings.INSTALLED_APPS)
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
>     app_config.import_models(all_models)
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
>     self.models_module = import_module(models_module_name)
>   File "/opt/circleci/python/2.7.10/lib/python2.7/importlib/__init__.py", line 37, in import_module
>     __import__(name)
>   File "/home/ubuntu/appname/appname/apps/eav/models.py", line 44, in <module>
>     from sortedm2m.fields import SortedManyToManyField
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/sortedm2m/fields.py", line 17, in <module>
>     from .forms import SortedMultipleChoiceField
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/sortedm2m/forms.py", line 25, in <module>
>     class SortedCheckboxSelectMultiple(forms.CheckboxSelectMultiple):
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/sortedm2m/forms.py", line 26, in SortedCheckboxSelectMultiple
>     class Media:
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/sortedm2m/forms.py", line 28, in Media
>     static('sortedm2m/widget.js'),
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 9, in static
>     return staticfiles_storage.url(path)
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in url
>     hashed_name = self.stored_name(clean_name)
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 280, in stored_name
>     cache_name = self.clean_name(self.hashed_name(name))
>   File "/home/ubuntu/virtualenvs/venv-2.7.10/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 94, in hashed_name
>     (clean_name, self))
> ValueError: The file 'sortedm2m/widget.js' could not be found with <pipeline.storage.PipelineCachedStorage object at 0x7f078590ae10>.

> ./manage.py collectstatic --no-input returned exit code 1

I’ve changed my app’s name to appname in the above log.

Edit:
If I change STATICFILES_STORAGE to 'django.contrib.staticfiles.storage.StaticFilesStorage' it works fine. But it doesn’t work with Pipeline.

Any idea how I can make it work with Pipeline too?


#2