0

On a Django 1.11 app deployed to Heroku. The Django management command findstatic is saying that it cannot find a file angular.min.js even though the file appears to be in a folder findstatic is checking.

$ heroku run python manage.py findstatic --verbosity 2 angular.min.js
Running python manage.py findstatic --verbosity 2 angular.min.js
No matching file found for 'angular.min.js'.

Looking in the following locations:
  /app/static
  /app/.heroku/python/lib/python3.6/site-packages/django/contrib/admin/static
  /app/.heroku/python/lib/python3.6/site-packages/django_extensions/static
  /app/.heroku/src/django-floppyforms/floppyforms/static
  /app/.heroku/python/lib/python3.6/site-packages/rest_framework/static
$ heroku run ls /app/static/angular/
Running ls /app/static/angular/
angular.min.js  controllers.js

So it appears that angular.min.js is at /app/static/angular/. Why does findstatic not find it?

Relevant part of settings.py:

I followed Heroku's instructions for service Static Files with Django:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "/static/"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"),]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    # ...others here too
]

Also, whitenoise in requirements.txt

Related questions that did not solve my problem:

Django findstatic : No matching file found (STATICFILES_DIRS appears to me to be correctly set up)
django findstatic not looking in every directory (In my situation, findstatic appears to be looking in the correct parent directory)

jchung
  • 903
  • 1
  • 11
  • 23
  • 1
    It must look under /app/static/angular but it is looking in /app/static – Gilbish Kosma Sep 13 '19 at 18:02
  • try to place your angular.min.js in app/static/ – Gilbish Kosma Sep 13 '19 at 18:02
  • what is the path of angular.min.js you are using in html file? it should be /angular/angular.min.js if you want to access from angular file – Gilbish Kosma Sep 13 '19 at 18:08
  • Or leave it there and try `heroku run python manage.py findstatic --verbosity 2 angular/angular.min.js`. – ChrisGPT was on strike Sep 13 '19 at 18:11
  • `$ heroku run python manage.py findstatic --verbosity 2 angular/angular.min.js` This does find the file. I assumed findstatic would look into sub-folders. Guess not. – jchung Sep 13 '19 at 18:23
  • The HTML template is loading the file with `{% static 'angular/angular.min.js' %}` so that appears to be fine. However (as you probably guessed) there's an error for that. I'll post a different SO question for that error, because it's not a `findstatic` error. Thanks. – jchung Sep 13 '19 at 18:24
  • Update: the other question is at https://stackoverflow.com/questions/57928946/django-valueerror-missing-staticfiles-manifest-entry-but-the-manifest-appears – jchung Sep 13 '19 at 18:52

0 Answers0