Athanasios Garyfalos
2018-03-05 11:55:22 UTC
Hello everyone,
I am new to Django Rest Framework and to REST in general.
I followed the really nice REST-Tutorials
<http://www.django-rest-framework.org/tutorial/1-serialization/> and I
managed to make an API that on my local host is working perfectly.
My problem is when I am deploying it on the Heroku I get 404 error
regarding the Jana scripts css etc.
I following the logs with (heroku logs --tail --app myApi) and I see the
following:
2018-03-05T11:38:18.629896+00:00 app[web.1]: - 10.104.55.179 - -
[05/Mar/2018:12:38:18 +0100] "GET /static/rest_framework/js/default.js
HTTP/1.1" 404 109 "https://myApi.herokuapp.com/" "Mozilla/5.0 (X11; Linux
x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186
Safari/537.36"
2018-03-05T11:38:18.690858+00:00 app[web.1]: - 10.104.55.179 - -
[05/Mar/2018:12:38:18 +0100] "GET /favicon.ico HTTP/1.1" 404 85
"https://myApi.herokuapp.com/" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
2018-03-05T11:38:18.692141+00:00 heroku[router]: - at=info method=GET
path="/favicon.ico" host=myApi.herokuapp.com
request_id=ec4d4ed0-19a9-4785-84b5-452e90239bfb fwd="5.59.34.149"
dyno=web.1 connect=1ms service=3ms status=404 bytes=260 protocol=https
2018-03-05T11:38:18.165004+00:00 heroku[router]: - at=info method=GET
path="/static/rest_framework/css/prettify.css" host=myApi.herokuapp.com
request_id=f9be6b23-eb9f-4efd-81e0-929772f0dac3 fwd="5.59.34.149"
dyno=web.1 connect=0ms service=2ms status=404 bytes=288 protocol=https
2018-03-05T11:38:18.205046+00:00 heroku[router]: - at=info method=GET
path="/static/rest_framework/js/prettify-min.js" host=myApi.herokuapp.com
request_id=385a1ec6-8951-4ac1-845a-757c600fff70 fwd="5.59.34.149"
dyno=web.1 connect=1ms service=3ms status=404 bytes=290 protocol=https
Sample of my tree structure:
$ tree -L 2 myApi/
myApi/
âââ db.sqlite3
âââ env
â âââ bin
â âââ include
â âââ lib
â âââ local
â âââ pip-selfcheck.json
âââ manage.py
âââ Pipfile
âââ Pipfile.lock
âââ Procfile
âââ Procfile~
âââ README.md
âââ requirements.txt
âââ snippets
â âââ admin.py
â âââ admin.pyc
â âââ apps.py
â âââ apps.pyc
â âââ __init__.py
â âââ __init__.pyc
â âââ migrations
â âââ models.py
â âââ models.pyc
â âââ permissions.py
â âââ permissions.pyc
â âââ serializers.py
â âââ serializers.pyc
â âââ tests.py
â âââ urls.py
â âââ urls.pyc
â âââ views.py
â âââ views.pyc
âââ myApi
âââ __init__.py
âââ __init__.pyc
âââ settings.py
âââ settings.pyc
âââ static
âââ urls.py
âââ urls.pyc
âââ wsgi.py
âââ wsgi.pyc
9 directories, 34 files
I created my static file with the following command:
python manage.py collectstatic source: Managing static files (e.g. images,
JavaScript, CSS) <https://docs.djangoproject.com/en/2.0/howto/static-files/>
.
In my settings.py file I have:
# All settings common to all environments
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
I guess this correct configuration or at least this is what I found on line.
I can see the files in my Git repo but I can not understand why they are
not populated on the Heroku.
I guess this is a trivial question but if you do not have the knowledge on
the subject it can get very very difficult to find the solution.
Does any one had this problem before?
Thank you in advance for your time and effort reading and replying to my
question.
If you require any further information do not hesitate to come in contact
with me.
I am new to Django Rest Framework and to REST in general.
I followed the really nice REST-Tutorials
<http://www.django-rest-framework.org/tutorial/1-serialization/> and I
managed to make an API that on my local host is working perfectly.
My problem is when I am deploying it on the Heroku I get 404 error
regarding the Jana scripts css etc.
I following the logs with (heroku logs --tail --app myApi) and I see the
following:
2018-03-05T11:38:18.629896+00:00 app[web.1]: - 10.104.55.179 - -
[05/Mar/2018:12:38:18 +0100] "GET /static/rest_framework/js/default.js
HTTP/1.1" 404 109 "https://myApi.herokuapp.com/" "Mozilla/5.0 (X11; Linux
x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186
Safari/537.36"
2018-03-05T11:38:18.690858+00:00 app[web.1]: - 10.104.55.179 - -
[05/Mar/2018:12:38:18 +0100] "GET /favicon.ico HTTP/1.1" 404 85
"https://myApi.herokuapp.com/" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"
2018-03-05T11:38:18.692141+00:00 heroku[router]: - at=info method=GET
path="/favicon.ico" host=myApi.herokuapp.com
request_id=ec4d4ed0-19a9-4785-84b5-452e90239bfb fwd="5.59.34.149"
dyno=web.1 connect=1ms service=3ms status=404 bytes=260 protocol=https
2018-03-05T11:38:18.165004+00:00 heroku[router]: - at=info method=GET
path="/static/rest_framework/css/prettify.css" host=myApi.herokuapp.com
request_id=f9be6b23-eb9f-4efd-81e0-929772f0dac3 fwd="5.59.34.149"
dyno=web.1 connect=0ms service=2ms status=404 bytes=288 protocol=https
2018-03-05T11:38:18.205046+00:00 heroku[router]: - at=info method=GET
path="/static/rest_framework/js/prettify-min.js" host=myApi.herokuapp.com
request_id=385a1ec6-8951-4ac1-845a-757c600fff70 fwd="5.59.34.149"
dyno=web.1 connect=1ms service=3ms status=404 bytes=290 protocol=https
Sample of my tree structure:
$ tree -L 2 myApi/
myApi/
âââ db.sqlite3
âââ env
â âââ bin
â âââ include
â âââ lib
â âââ local
â âââ pip-selfcheck.json
âââ manage.py
âââ Pipfile
âââ Pipfile.lock
âââ Procfile
âââ Procfile~
âââ README.md
âââ requirements.txt
âââ snippets
â âââ admin.py
â âââ admin.pyc
â âââ apps.py
â âââ apps.pyc
â âââ __init__.py
â âââ __init__.pyc
â âââ migrations
â âââ models.py
â âââ models.pyc
â âââ permissions.py
â âââ permissions.pyc
â âââ serializers.py
â âââ serializers.pyc
â âââ tests.py
â âââ urls.py
â âââ urls.pyc
â âââ views.py
â âââ views.pyc
âââ myApi
âââ __init__.py
âââ __init__.pyc
âââ settings.py
âââ settings.pyc
âââ static
âââ urls.py
âââ urls.pyc
âââ wsgi.py
âââ wsgi.pyc
9 directories, 34 files
I created my static file with the following command:
python manage.py collectstatic source: Managing static files (e.g. images,
JavaScript, CSS) <https://docs.djangoproject.com/en/2.0/howto/static-files/>
.
In my settings.py file I have:
# All settings common to all environments
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
I guess this correct configuration or at least this is what I found on line.
I can see the files in my Git repo but I can not understand why they are
not populated on the Heroku.
I guess this is a trivial question but if you do not have the knowledge on
the subject it can get very very difficult to find the solution.
Does any one had this problem before?
Thank you in advance for your time and effort reading and replying to my
question.
If you require any further information do not hesitate to come in contact
with me.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.