4

Things I have verified:

  • my collectstatic directory (yes, I call it like that, to reduce confussion with static source directories) is in my repo (via a .gitkeep file) (as advised in the heroku documentation)
  • heroku run python manage.py collectstatic --dry-run --noinput works (suggested here)
  • collectstatic is not forcefully disabled: heroku config:add DISABLE_COLLECTSTATIC=0
  • I am pushing a new commit (so heroku is actually deploying)

Still, collectstatic is not run. What more could I check?

EDIT

Also, I properly define STATIC_ROOT in settings.py. Relevant section below:

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'collectstatic/')

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

EDIT2

My installed apps are just stock django 1.9:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

EDIT3

One thing I must mention, which is maybe relevant: DISABLE_COLLECTSTATIC was set to 1 previously (so forcefully disabled) for this one heroku app, but I have made sure it is now set to 0.

Maybe a bug in Heroku prevents it from using the latest value? I guess the only way to check this is to create a new heroku app.

Community
  • 1
  • 1
blueFast
  • 41,341
  • 63
  • 198
  • 344
  • Did you add the `collectstatic` directory to your STATIC_DIRS in your settings.py? – Remi Smirra Jan 07 '16 at 09:33
  • @Remi: sure, question editted. Actually not to `STATICFILES_DIRS` (that's what you mean, right?) but to `STATIC_ROOT`: `collectstatic` is the output directory. The source static directories are defined in `STATICFILES_DIRS` and I just call them `static` – blueFast Jan 07 '16 at 09:36
  • Have you tried adding the directory specifically like this: STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'collectstatic'), ) – Remi Smirra Jan 07 '16 at 09:42
  • 1
    No, and I don't want to since that does not make sense. `collecstatic` is not a source directory, and should not be searched when collecting static files (which is the meaning of `STATICFILES_DIRS`) – blueFast Jan 07 '16 at 09:44
  • ah ok, understood. And you only have one settings file that you are using? – Remi Smirra Jan 07 '16 at 09:45
  • Yes, only one `settings.py` (and currently a single `static` entry in `STATICFILES_DIRS`, but that is not relevant) – blueFast Jan 07 '16 at 09:53
  • And is staticfiles included in INSTALLED_APPS in that settings file? – Daniel Roseman Jan 07 '16 at 09:58
  • @DanielRoseman: yep! Question editted – blueFast Jan 07 '16 at 10:01
  • have you tried without the dry-run flag? – Remi Smirra Jan 07 '16 at 10:20
  • @Remi: yes, and when called manually it works, but that is not good for production, since that creates collectstatic in the context of the one-off dyno, which is not what I need. That **is exactly** what `heroku push` should trigger, but is not. – blueFast Jan 07 '16 at 10:24

1 Answers1

0

So, no idea what is going on, but creating a new Heroku instance and pushing to it with an empty configuration is actually triggering collectstatic.

I suspect Heroku is not properly evaluating changes to DISABLE_COLLECTSTATIC.

EDIT

Actually, it seems DISABLE_COLLECTSTATIC=0 also prevents collectstatic to run. To make sure collectstatic runs, do:

heroku config:unset DISABLE_COLLECTSTATIC

I would say the Heroku documentation is a bit confusing, since it seems to imply that DISABLE_COLLECTSTATIC=0 will in fact run collectstatic - but it doesn't.

blueFast
  • 41,341
  • 63
  • 198
  • 344