简体   繁体   中英

URLconf error on Django Heroku deployment

I am getting the following error on my Django Heroku deployment, not sure what is causing it?:

Page not found (404)
Request Method: GET
Request URL:    https://blogpod.herokuapp.com/
Using the URLconf defined in blogpodapi.urls, Django tried these URL patterns, in this order:
^admin/
^api/
^favicon\.ico$
^media\/(?P<path>.*)$
The current URL, , didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

The log generated by Heroku is as follows:

2016-08-11T12:00:13.231906+00:00 heroku[web.1]: Process exited with status 3
2016-08-11T12:00:13.085417+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [3] [INFO] Starting gunicorn 19.6.0
2016-08-11T12:00:13.086164+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [3] [INFO] Using worker: sync
2016-08-11T12:00:13.086036+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [3] [INFO] Listening at: http://0.0.0.0:28935 (3)
2016-08-11T12:00:13.094899+00:00 app[web.1]: Traceback (most recent call last):
2016-08-11T12:00:13.094908+00:00 app[web.1]:     worker.init_process()
2016-08-11T12:00:13.094885+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [9] [ERROR] Exception in worker process
2016-08-11T12:00:13.094908+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
2016-08-11T12:00:13.091098+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [9] [INFO] Booting worker with pid: 9
2016-08-11T12:00:13.094907+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
2016-08-11T12:00:13.094910+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2016-08-11T12:00:13.094909+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
2016-08-11T12:00:13.094928+00:00 app[web.1]:     __import__(module)
2016-08-11T12:00:13.094924+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2016-08-11T12:00:13.094926+00:00 app[web.1]:     return self.load_wsgiapp()
2016-08-11T12:00:13.094927+00:00 app[web.1]:     return util.import_app(self.app_uri)
2016-08-11T12:00:13.094925+00:00 app[web.1]:     self.callable = self.load()
2016-08-11T12:00:13.094909+00:00 app[web.1]:     self.load_wsgi()
2016-08-11T12:00:13.094925+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2016-08-11T12:00:13.094927+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2016-08-11T12:00:13.094928+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 357, in import_app
2016-08-11T12:00:13.094929+00:00 app[web.1]:   File "/app/blogpodapi/__init__.py", line 5, in <module>
2016-08-11T12:00:13.094930+00:00 app[web.1]:     from .celery import app as celery_app
2016-08-11T12:00:13.094946+00:00 app[web.1]:     from celery import Celery
2016-08-11T12:00:13.095036+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [9] [INFO] Worker exiting (pid: 9)
2016-08-11T12:00:13.116166+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [3] [INFO] Shutting down: Master
2016-08-11T12:00:13.094931+00:00 app[web.1]:     from celery import Celery
2016-08-11T12:00:13.094945+00:00 app[web.1]:   File "/app/blogpodapi/celery.py", line 3, in <module>
2016-08-11T12:00:13.094947+00:00 app[web.1]: ImportError: cannot import name Celery
2016-08-11T12:00:13.094930+00:00 app[web.1]:   File "/app/blogpodapi/celery.py", line 3, in <module>
2016-08-11T12:00:13.116300+00:00 app[web.1]: [2016-08-11 12:00:13 +0000] [3] [INFO] Reason: Worker failed to boot.
2016-08-11T13:50:33.664042+00:00 heroku[slug-compiler]: Slug compilation finished
2016-08-11T13:50:33.664034+00:00 heroku[slug-compiler]: Slug compilation started
2016-08-11T13:50:33.427856+00:00 heroku[api]: Release v10 created by methuselah@hotmail.co.uk
2016-08-11T13:50:33.427821+00:00 heroku[api]: Deploy cda9e28 by methuselah@hotmail.co.uk
2016-08-11T13:50:33.977599+00:00 heroku[web.1]: State changed from crashed to starting
2016-08-11T13:50:39.111777+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath blogpodapi blogpodapi.wsgi`
2016-08-11T13:50:41.177637+00:00 app[web.1]: [2016-08-11 13:50:41 +0000] [3] [INFO] Starting gunicorn 19.6.0
2016-08-11T13:50:41.200609+00:00 app[web.1]: [2016-08-11 13:50:41 +0000] [12] [INFO] Booting worker with pid: 12
2016-08-11T13:50:41.178100+00:00 app[web.1]: [2016-08-11 13:50:41 +0000] [3] [INFO] Using worker: sync
2016-08-11T13:50:41.181609+00:00 app[web.1]: [2016-08-11 13:50:41 +0000] [9] [INFO] Booting worker with pid: 9
2016-08-11T13:50:41.178025+00:00 app[web.1]: [2016-08-11 13:50:41 +0000] [3] [INFO] Listening at: http://0.0.0.0:49918 (3)
2016-08-11T13:50:42.773771+00:00 heroku[web.1]: State changed from starting to up
2016-08-11T13:51:16.618289+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=a75e5e61-ea8f-4782-b620-cc5cc75b9f7b fwd="81.140.173.71" dyno=web.1 connect=0ms service=275ms status=404 bytes=2347
2016-08-11T13:51:16.572682+00:00 app[web.1]: Not Found: /
2016-08-11T13:51:16.998620+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=blogpod.herokuapp.com request_id=4d03a815-63c3-4af2-bc59-7961921d1fe6 fwd="81.140.173.71" dyno=web.1 connect=0ms service=6ms status=404 bytes=2380
2016-08-11T13:51:16.954410+00:00 app[web.1]: Not Found: /favicon.ico
2016-08-11T13:51:18.788369+00:00 app[web.1]: Not Found: /
2016-08-11T13:51:18.833864+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=1872905b-5428-4f86-84f9-004fc09f678f fwd="81.140.173.71" dyno=web.1 connect=1ms service=110ms status=404 bytes=2347
2016-08-11T13:51:28.890453+00:00 app[web.1]: Not Found: /
2016-08-11T13:51:29.083208+00:00 app[web.1]: Not Found: /favicon.ico
2016-08-11T13:51:28.901745+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=32407ba8-9172-4100-ab3e-ad94556a7ad8 fwd="81.140.173.71" dyno=web.1 connect=1ms service=9ms status=404 bytes=2348
2016-08-11T13:51:29.092764+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=blogpod.herokuapp.com request_id=8162cd11-0e2b-4b1e-b399-d1da4f54aaf2 fwd="81.140.173.71" dyno=web.1 connect=1ms service=8ms status=404 bytes=2381
2016-08-11T14:00:02.834694+00:00 app[web.1]: Not Found: /
2016-08-11T14:00:02.878192+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=1e9378d0-1da8-4043-9ed3-4de28596dcb8 fwd="81.140.173.71" dyno=web.1 connect=0ms service=5ms status=404 bytes=2347
2016-08-11T14:00:43.156178+00:00 heroku[api]: Deploy 9d0f8a9 by methuselah@hotmail.co.uk
2016-08-11T14:00:43.156178+00:00 heroku[api]: Release v11 created by methuselah@hotmail.co.uk
2016-08-11T14:00:43.420375+00:00 heroku[slug-compiler]: Slug compilation finished
2016-08-11T14:00:43.420369+00:00 heroku[slug-compiler]: Slug compilation started
2016-08-11T14:00:43.961889+00:00 heroku[web.1]: Restarting
2016-08-11T14:00:43.962570+00:00 heroku[web.1]: State changed from up to starting
2016-08-11T14:00:47.162710+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-08-11T14:00:47.870052+00:00 app[web.1]: [2016-08-11 14:00:47 +0000] [3] [INFO] Handling signal: term
2016-08-11T14:00:48.024476+00:00 heroku[web.1]: Process exited with status 0
2016-08-11T14:00:47.888983+00:00 app[web.1]: [2016-08-11 14:00:47 +0000] [3] [INFO] Shutting down: Master
2016-08-11T14:00:47.871014+00:00 app[web.1]: [2016-08-11 14:00:47 +0000] [12] [INFO] Worker exiting (pid: 12)
2016-08-11T14:00:47.869197+00:00 app[web.1]: [2016-08-11 14:00:47 +0000] [9] [INFO] Worker exiting (pid: 9)
2016-08-11T14:00:53.606738+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath blogpodapi blogpodapi.wsgi`
2016-08-11T14:00:56.402633+00:00 app[web.1]: [2016-08-11 14:00:56 +0000] [3] [INFO] Starting gunicorn 19.6.0
2016-08-11T14:00:56.409059+00:00 app[web.1]: [2016-08-11 14:00:56 +0000] [9] [INFO] Booting worker with pid: 9
2016-08-11T14:00:56.403334+00:00 app[web.1]: [2016-08-11 14:00:56 +0000] [3] [INFO] Using worker: sync
2016-08-11T14:00:56.403205+00:00 app[web.1]: [2016-08-11 14:00:56 +0000] [3] [INFO] Listening at: http://0.0.0.0:8099 (3)
2016-08-11T14:00:56.474461+00:00 app[web.1]: [2016-08-11 14:00:56 +0000] [12] [INFO] Booting worker with pid: 12
2016-08-11T14:00:57.424122+00:00 heroku[web.1]: State changed from starting to up
2016-08-11T14:00:59.703603+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=e434a2df-e8a7-4ba3-abb2-e18225935469 fwd="81.140.173.71" dyno=web.1 connect=4ms service=254ms status=404 bytes=2461
2016-08-11T14:00:59.674543+00:00 app[web.1]: Not Found: /
2016-08-11T14:01:37.434523+00:00 app[web.1]: Not Found: /
2016-08-11T14:01:37.469187+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=94ab0e10-894d-4b3a-a7c2-88d21d2adf88 fwd="81.140.173.71" dyno=web.1 connect=1ms service=16ms status=404 bytes=2461
2016-08-11T14:01:38.605473+00:00 app[web.1]: Not Found: /
2016-08-11T14:01:38.635562+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=106ca9e9-8699-48fe-b399-4fc85ad68ec5 fwd="81.140.173.71" dyno=web.1 connect=0ms service=113ms status=404 bytes=2461
2016-08-11T14:01:39.784904+00:00 app[web.1]: Not Found: /
2016-08-11T14:01:39.815800+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=a62737a0-47a9-4624-aa74-ada56a87c831 fwd="81.140.173.71" dyno=web.1 connect=0ms service=11ms status=404 bytes=2461
2016-08-11T14:36:35.901858+00:00 heroku[web.1]: State changed from up to down
2016-08-11T14:36:35.901149+00:00 heroku[web.1]: Idling
2016-08-11T14:36:40.049130+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-08-11T14:36:41.205660+00:00 heroku[web.1]: Process exited with status 0
2016-08-11T14:36:41.029945+00:00 app[web.1]: [2016-08-11 14:36:41 +0000] [12] [INFO] Worker exiting (pid: 12)
2016-08-11T14:36:41.029933+00:00 app[web.1]: [2016-08-11 14:36:41 +0000] [9] [INFO] Worker exiting (pid: 9)
2016-08-11T14:36:41.031588+00:00 app[web.1]: [2016-08-11 14:36:41 +0000] [3] [INFO] Handling signal: term
2016-08-11T14:36:41.068936+00:00 app[web.1]: [2016-08-11 14:36:41 +0000] [3] [INFO] Shutting down: Master
2016-08-11T15:12:03.453222+00:00 heroku[web.1]: Unidling
2016-08-11T15:12:03.453577+00:00 heroku[web.1]: State changed from down to starting
2016-08-11T15:12:08.706728+00:00 heroku[web.1]: Starting process with command `gunicorn --pythonpath blogpodapi blogpodapi.wsgi`
2016-08-11T15:12:11.131960+00:00 app[web.1]: [2016-08-11 15:12:11 +0000] [3] [INFO] Using worker: sync
2016-08-11T15:12:11.131854+00:00 app[web.1]: [2016-08-11 15:12:11 +0000] [3] [INFO] Listening at: http://0.0.0.0:4732 (3)
2016-08-11T15:12:11.131379+00:00 app[web.1]: [2016-08-11 15:12:11 +0000] [3] [INFO] Starting gunicorn 19.6.0
2016-08-11T15:12:11.220853+00:00 app[web.1]: [2016-08-11 15:12:11 +0000] [12] [INFO] Booting worker with pid: 12
2016-08-11T15:12:11.136374+00:00 app[web.1]: [2016-08-11 15:12:11 +0000] [9] [INFO] Booting worker with pid: 9
2016-08-11T15:12:12.474341+00:00 heroku[web.1]: State changed from starting to up
2016-08-11T15:12:13.158176+00:00 app[web.1]: Not Found: /
2016-08-11T15:12:13.178070+00:00 heroku[router]: at=info method=GET path="/" host=blogpod.herokuapp.com request_id=f1326563-c66c-4aa1-a75c-0ffb1a8796f1 fwd="81.140.173.71" dyno=web.1 connect=1ms service=273ms status=404 bytes=2462

My folder structure is as follows:

在此处输入图片说明

My urls.py looks like this:

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic.base import RedirectView

favicon_view = RedirectView.as_view(url='/static/favicon.ico', permanent=True)

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^api/', include('api.urls')),
    url(r'^favicon\.ico$', favicon_view),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

To define the root url you have to add this pattern '^$':

url(r'^$', view)

Then it matches to your case https://blogpod.herokuapp.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM