0

I'm beginning to fear I'll never get my site launched.

I've launched an app on heroku, but I can't run heroku run python manage.py collectstatic without getting an OSError:

Traceback:

Running python manage.py collectstatic on ⬢ tallymusic... up, run.1934 (Free)
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 199, in handle
    collected = self.collect()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, in collect
    for path, storage in finder.list(self.ignore_patterns):
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
    for path in utils.get_files(storage, ignore_patterns):
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
    directories, files = storage.listdir(location)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 397, in listdir
    for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/app/tallymusicsite/assets'

Here's my settings.py static settings:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'tallymusic/assets'),
    os.path.join(BASE_DIR, 'tallymusic/assets/css'),
    os.path.join(BASE_DIR, 'tallymusic/assets/images'),
    os.path.join(BASE_DIR, 'tallymusic/assets/js'),
    os.path.join(BASE_DIR, 'tallymusic/assets/venue_images')
)

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

I'm pretty confident the error comes from my STATICFILES_DIRS setting, but I can't figure it out. I've read so many answers on this error on StackOverflow, and tried every permutation suggested, including:

'../tallymusic/assets'
'../tallymusicsite/assets'
'app/tallymusic/assets'
'app/tallymusicsite/assets'
'tallymusic/tallymusicsite/assets'

etc. etc. etc.

I don't even really know what project name I should be using. My outer folder has always been called tallymusic but the folder holding the settings.py file is called tallymusicsite. Does that make tallymusicsite the project name?

Obviously I don't understand something basic. The Django documentation on static files isn't helping either. I can't even describe how much I would appreciate some help with this. Please let me know if I should have provided more information.

Edited to add:

Here's my file structure:

tallymusic
-- manage.py
--> apps, etc.
...
--> assets # actually has the files
--> tallymusicsite
---- settings.py
----> assets # read on a SO post that this is where I want the folder?
...

Let me know if you need more of the file structure.

Danny
  • 470
  • 1
  • 4
  • 21
  • try changing STATIC_URL = '/static/' to STATIC_URL = '/assets/'. You have named everything assets but for some reason use static there. if you css etc where under a folder called static then you would use static but from your other file paths it looks like you have them under a folder called assets. – Taylor Aug 09 '18 at 22:12
  • Also images are generally stored under media which has its own MEDIA_ROOT and MEDIA_URL https://docs.djangoproject.com/en/2.1/ref/settings/#media-root – Taylor Aug 09 '18 at 22:15
  • It's frustrating because the tutorial I followed used assets instead of static, so I don't know where static is required and where it's just a variable name. All the docs refer to static. The change you suggested is still throwing the same error. Appreciate the help, though. – Danny Aug 09 '18 at 22:15
  • It usually just a naming choice, a lot of people/tutorials use static, I personally use assets, it doesn't really matter just be consistent. If you turn debug to true does it work then? – Taylor Aug 09 '18 at 22:23
  • Unfortunately not. – Danny Aug 09 '18 at 22:25
  • can you post your file structure for assets? – Taylor Aug 09 '18 at 22:28
  • Edited the post. Let me know if you need more. Thank you for your help. – Danny Aug 09 '18 at 22:38
  • `STATIC_ROOT = os.environ.get('STATIC_ROOT', os.path.join(PROJECT_ROOT, 'assets')) STATIC_URL = BASE_URL + 'assets/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'assets'), )` try to use this, remove the / at the beginning of assets in the static url and get rid of everything in dirs except assets(cut and paste them some place for safe keeping) – Taylor Aug 09 '18 at 22:48
  • Also do you have two assets folders? – Taylor Aug 09 '18 at 22:50
  • It's still throwing the same error. Should I have BASE_URL AND PROJECT_ROOT assigned somewhere? I haven't seen those in tutorials. Re: Two assets folders, I read on a SO answer that Django looks for an assets folder next to `settings.py`, so I added one there. It is empty except for a blank file so git will see it. The files I want are in the assets folder in the same directory as `manage.py`. – Danny Aug 09 '18 at 22:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/177764/discussion-between-taylor-and-danny). – Taylor Aug 09 '18 at 23:17

0 Answers0