Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku & Django: "OSError: No such file or directory: '/app/{myappname}/static'"

I have a Django app on Heroku. I am having some problems with static files (they are loading in one Heroku environment but not another), so I tried the debug command recommended here.

$ heroku run python manage.py collectstatic --noinput Running `python manage.py collectstatic --noinput` attached to terminal... up, run.8771 OSError: [Errno 2] No such file or directory: '/app/{myappname}/static' 

Here is my settings.py, which is the same thing Heroku recommends:

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

I get the error whether or not I actually have a directory "static" at the root level in my Git repo (tested it both ways).

Any ideas?

like image 795
RexE Avatar asked Oct 11 '13 16:10

RexE


People also ask

What is Heroku used for?

What is Heroku? Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. Our platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.

Is Heroku like AWS?

Heroku is based on AWS and its services are simpler to use than Elastic Compute Cloud. It supports efficient building, deploying, and fast scaling. It is popular for its add-on capabilities as it supports many alerts and management tools.

Is Heroku for free?

Free Services on HerokuHeroku offers a free plan to help you learn and get started on the platform. Heroku Buttons and Buildpacks are free, and many Heroku Add-ons also offer a free plan. Experiment easily with different technologies to discover what works best for you and your apps.

Is Heroku owned by Google?

Heroku was acquired by Salesforce in 2010 for $212 million.


2 Answers

It's looking for a folder named 'static' that's next to the settings.py, i.e. in the project folder, not at the root of the git repo.

git root/ git root/{app name} git root/{app name}/settings.py git root/{app name}/static/         <- this is what you're missing 

Note that empty folders aren't tracked by git, so you'll have to put a blank file in there if it's empty. Alternatively, remove the STATICFILES_DIRS setting until you need it.

like image 83
joerick Avatar answered Sep 26 '22 01:09

joerick


I just had this same problem, and here's the solution that worked for me:

I changed:

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

to:

STATICFILES_DIRS = (     os.path.join(BASE_DIR, 'myappfolder/static'), ) 
like image 27
Michelle Glauser Avatar answered Sep 24 '22 01:09

Michelle Glauser