0

I have a django application and trying to load the front end from by django project. My index.html is:

<link rel="icon" type="image/x-icon" href="favicon.ico">
  {% load static %}
<link rel="stylesheet" href="{% static "styles.38614f36c93ac671679e.css" %}"></head>
<body>
<app-root></app-root>
{% load static %}
<script type="text/javascript" src="{% static "runtime.a66f828dca56eeb90e02.js" %}"></script><script type="text/javascript" src="{% static "polyfills.f3fc5ca24d1323624670.js" %}"></script><script type="text/javascript" src="{% static "scripts.5bde77e84291ce59c080.js" %}"></script><script type="text/javascript" src="{% static "main.e7b9143f2f482d6d3cc7.js" %}"></script></body>
</html>

and in settings.py of project file i have added static file settings:

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

my project structure is:

apt.yml     DCMS_API/  infra/  manage.py*    odbc-cfg/  requirements.txt  static/       templates/
Authorize/  facility/  manifest.yml  Procfile   runtime.txt

when i uploaded the code on cloud foundry and tried to run the application it says

ERR Not Found: /static/runtime.a66f828dca56eeb90e02.js
ERR Not Found: /static/styles.38614f36c93ac671679e.css
ERR Not Found: /static/polyfills.f3fc5ca24d1323624670.js
ERR Not Found: /static/scripts.5bde77e84291ce59c080.js
ERR Not Found: /static/main.e7b9143f2f482d6d3cc7.js

What am i missing?

geek
  • 794
  • 3
  • 16
  • 41
  • 1
    Is BASE_DIR set correctly? It almost looks like it's trying to find the file at `/static` which won't exist on CF. Your files will be under `/home/vcap/app/static` or `/app/static` (`/app` is a symlink to the former location). Maybe try the hardcoded path and see if that helps? – Daniel Mikusa Nov 18 '19 at 20:07
  • It worked after adding static_dir where we mention static folder but it load only home page when i try to load other pages from ui it says that file not found – geek Nov 19 '19 at 18:55

1 Answers1

0

did you run python manage.py collectstatic ?

Epikstar
  • 69
  • 5