gpt4 book ai didi

django - "Internal Server Error"将 Django 应用程序部署到 Heroku

转载 作者:行者123 更新时间:2023-12-04 15:00:04 24 4
gpt4 key购买 nike

我有一个试图部署到 Heroku 的 Django 应用程序。我密切关注 Heroku 文档,没有遇到任何实际问题。但是,在推送到 Heroku 之后,当我在线访问该应用程序时,我看到了“内部服务器错误”。我在终端(下)中没有看到任何明显的错误。这是我第一次使用 Heroku,所以可能在某个地方出现了新手错误。帮助表示赞赏。

(venv)suraj-kapoors-computer:listing surajkapoor$ 
(venv)suraj-kapoors-computer:listing surajkapoor$
(venv)suraj-kapoors-computer:listing surajkapoor$ pip freeze > requirements.txt
(venv)suraj-kapoors-computer:listing surajkapoor$ venv
-bash: venv: command not found
(venv)suraj-kapoors-computer:listing surajkapoor$ git init
Initialized empty Git repository in /Users/surajkapoor/Desktop/listing/.git/
(venv)suraj-kapoors-computer:listing surajkapoor$ git add .
(venv)suraj-kapoors-computer:listing surajkapoor$ git commit -m "listings"
[master (root-commit) 62e03eb] listings
38 files changed, 939 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 Procfile
create mode 100644 listing/__init__.py
create mode 100644 listing/settings.py
create mode 100644 listing/urls.py
create mode 100644 listing/wsgi.py
create mode 100644 manage.py
create mode 100644 noticeboard/__init__.py
create mode 100644 noticeboard/admin.py
create mode 100644 noticeboard/media/images/717c798f-8c99-4bd2-b78d-59959b219aa1-620x372.jpeg
create mode 100644 noticeboard/media/images/717c798f-8c99-4bd2-b78d-59959b219aa1-620x372_1.jpeg
create mode 100644 noticeboard/media/images/717c798f-8c99-4bd2-b78d-59959b219aa1-620x372_2.jpeg
create mode 100644 noticeboard/media/images/images-1.jpeg
create mode 100644 noticeboard/media/images/images-2.jpeg
create mode 100644 noticeboard/media/images/images.jpeg
create mode 100644 noticeboard/media/images/images_1.jpeg
create mode 100644 noticeboard/media/images/imgres-1.jpeg
create mode 100644 noticeboard/media/images/imgres-2.jpeg
create mode 100644 noticeboard/media/images/imgres.jpeg
create mode 100644 noticeboard/media/images/imgres_1.jpeg
create mode 100644 noticeboard/media/images/imgres_2.jpeg
create mode 100644 noticeboard/media/images/imgres_3.jpeg
create mode 100644 noticeboard/media/images/imgres_4.jpeg
create mode 100644 noticeboard/migrations/0001_initial.py
create mode 100644 noticeboard/migrations/0002_auto__add_field_listings_image.py
create mode 100644 noticeboard/migrations/0003_auto__add_gallery__chg_field_listings_image__add_index_listings_image.py
create mode 100644 noticeboard/migrations/0004_auto__del_gallery__del_field_listings_image__add_field_listings_image1.py
create mode 100644 noticeboard/migrations/__init__.py
create mode 100644 noticeboard/models.py
create mode 100644 noticeboard/static/noticeboard/button.jpg
create mode 100644 noticeboard/static/noticeboard/left-scroll.jpg
create mode 100644 noticeboard/static/noticeboard/main.css
create mode 100644 noticeboard/static/noticeboard/main.js
create mode 100644 noticeboard/static/noticeboard/right-scroll.jpg
create mode 100644 noticeboard/templates/listings/index.html
create mode 100644 noticeboard/templates/listings/listings_detail.html
create mode 100644 noticeboard/tests.py
create mode 100644 noticeboard/urls.py
create mode 100644 noticeboard/views.py
create mode 100644 os.path.join(BASE_DIR, 'db.sqlite3')
create mode 100644 requirements.txt
(venv)suraj-kapoors-computer:listing surajkapoor$ heroku create
/Users/surajkapoor/.heroku/client/lib/heroku/updater.rb:164: warning: Insecure world writable dir /Users/surajkapoor/Desktop/listing in PATH, mode 040777
Creating thawing-wildwood-4650... done, stack is cedar
http://thawing-wildwood-4650.herokuapp.com/ | git@heroku.com:thawing-wildwood-4650.git
Git remote heroku added
(venv)suraj-kapoors-computer:listing surajkapoor$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of known hosts.
Counting objects: 45, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (45/45), 195.76 KiB | 53 KiB/s, done.
Total 45 (delta 6), reused 0 (delta 0)

-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.36)
-----> Installing Pip (1.3.1)
-----> Installing dependencies using Pip (1.3.1)
Downloading/unpacking Django==1.5.1 (from -r requirements.txt (line 1))
Running setup.py egg_info for package Django

Downloading/unpacking distribute==0.6.34 (from -r requirements.txt (line 2))
Running setup.py egg_info for package distribute

Downloading/unpacking dj-database-url==0.2.1 (from -r requirements.txt (line 3))
Downloading dj-database-url-0.2.1.tar.gz
Running setup.py egg_info for package dj-database-url

Downloading/unpacking django-toolbelt==0.0.1 (from -r requirements.txt (line 4))
Downloading django-toolbelt-0.0.1.tar.gz
Running setup.py egg_info for package django-toolbelt

Downloading/unpacking gunicorn==17.5 (from -r requirements.txt (line 5))
Running setup.py egg_info for package gunicorn

Downloading/unpacking psycopg2 (from django-toolbelt==0.0.1->-r requirements.txt (line 4))
Running setup.py egg_info for package psycopg2

Downloading/unpacking dj-static (from django-toolbelt==0.0.1->-r requirements.txt (line 4))
Downloading dj-static-0.0.5.tar.gz
Running setup.py egg_info for package dj-static

Downloading/unpacking static (from dj-static->django-toolbelt==0.0.1->-r requirements.txt (line 4))
Downloading static-0.4.tar.gz
Running setup.py egg_info for package static

Installing collected packages: Django, distribute, dj-database-url, django-toolbelt, gunicorn, psycopg2, dj-static, static
Running setup.py install for Django
changing mode of build/scripts-2.7/django-admin.py from 600 to 755

changing mode of /app/.heroku/python/bin/django-admin.py to 755
Found existing installation: distribute 0.6.36
Uninstalling distribute:
Successfully uninstalled distribute
Running setup.py install for distribute
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /app/.heroku/python/lib/python2.7/site-packages
Non-egg installation
Moving elements out of the way...
Already patched.
/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info already patched.

Installing easy_install script to /app/.heroku/python/bin
Installing easy_install-2.7 script to /app/.heroku/python/bin
After install bootstrap.
/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info already exists
Running setup.py install for dj-database-url

Running setup.py install for django-toolbelt

Running setup.py install for gunicorn

Installing gunicorn_paster script to /app/.heroku/python/bin
Installing gunicorn script to /app/.heroku/python/bin
Installing gunicorn_django script to /app/.heroku/python/bin
Running setup.py install for psycopg2
building 'psycopg2._psycopg' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -

Running setup.py install for dj-static

Running setup.py install for static

Installing static script to /app/.heroku/python/bin
Successfully installed Django distribute dj-database-url django-toolbelt gunicorn psycopg2 dj-static static
Cleaning up...

-----> Discovering process types
Procfile declares types -> web

-----> Compiled slug size: 30.2MB
-----> Launching... done, v3
http://thawing-wildwood-4650.herokuapp.com deployed to Heroku

To git@heroku.com:thawing-wildwood-4650.git
* [new branch] master -> master
(venv)suraj-kapoors-computer:listing surajkapoor$ heroku ps:scale web=1
/Users/surajkapoor/.heroku/client/lib/heroku/helpers.rb:103: warning: Insecure world writable dir /Users/surajkapoor/Desktop/listing in PATH, mode 040777
Scaling web dynos... done, now running 1
(venv)suraj-kapoors-computer:listing surajkapoor$ heroku ps
/Users/surajkapoor/.heroku/client/lib/heroku/helpers.rb:103: warning: Insecure world writable dir /Users/surajkapoor/Desktop/listing in PATH, mode 040777
=== web (1X): `gunicorn listing.wsgi`
web.1: up 2013/07/23 15:49:12 (~ 1m ago)

(venv)suraj-kapoors-computer:listing surajkapoor$ heroku open
/Users/surajkapoor/.heroku/client/lib/heroku/helpers.rb:103: warning: Insecure world writable dir /Users/surajkapoor/Desktop/listing in PATH, mode 040777
Opening thawing-wildwood-4650... done
(venv)suraj-kapoors-computer:listing surajkapoor$

Heroku 日志显示以下内容:
2013-07-23T17:16:01.137746+00:00 app[web.1]:     return node.render(context)
2013-07-23T17:16:01.138196+00:00 app[web.1]: pieces.append(force_text(getattr(self, piece)()))
2013-07-23T17:16:01.138196+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/encoding.py", line 99, in force_text
2013-07-23T17:16:01.138196+00:00 app[web.1]: s = s.__unicode__()
2013-07-23T17:16:01.138433+00:00 app[web.1]: default_translation = _fetch(settings.LANGUAGE_CODE)
2013-07-23T17:16:01.138433+00:00 app[web.1]: return _trans.ugettext(message)
2013-07-23T17:16:01.138433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 276, in ugettext
2013-07-23T17:16:01.138433+00:00 app[web.1]: return do_translate(message, 'ugettext')
2013-07-23T17:16:01.138433+00:00 app[web.1]: return func(*self.__args, **self.__kw)
2013-07-23T17:16:01.138433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/functional.py", line 130, in __text_cast
2013-07-23T17:16:01.138433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 258, in do_translate
2013-07-23T17:16:01.138433+00:00 app[web.1]: _default = translation(settings.LANGUAGE_CODE)
2013-07-23T17:16:01.138433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 172, in translation
2013-07-23T17:16:01.138433+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 71, in ugettext
2013-07-23T17:16:01.138882+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 154, in _fetch
2013-07-23T17:16:01.138882+00:00 app[web.1]: app = import_module(appname)
2013-07-23T17:16:01.138882+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2013-07-23T17:16:01.138882+00:00 app[web.1]: __import__(name)
2013-07-23T17:16:01.138882+00:00 app[web.1]: ImportError: No module named south
2013-07-23T17:16:01.445966+00:00 app[web.1]: response = middleware_method(request)
2013-07-23T17:16:01.445966+00:00 app[web.1]: Internal Server Error: /favicon.ico
2013-07-23T17:16:01.445966+00:00 app[web.1]: Traceback (most recent call last):
2013-07-23T17:16:01.445966+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 92, in get_response
2013-07-23T17:16:01.445966+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/middleware/common.py", line 69, in process_request
2013-07-23T17:16:01.445966+00:00 app[web.1]: if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
2013-07-23T17:16:01.445966+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 551, in is_valid_path
2013-07-23T17:16:01.445966+00:00 app[web.1]: resolve(path, urlconf)
2013-07-23T17:16:01.445966+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 440, in resolve
2013-07-23T17:16:01.445966+00:00 app[web.1]: return get_resolver(urlconf).resolve(path)
2013-07-23T17:16:01.446344+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 319, in resolve
2013-07-23T17:16:01.446344+00:00 app[web.1]: for pattern in self.url_patterns:
2013-07-23T17:16:01.446344+00:00 app[web.1]: patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2013-07-23T17:16:01.446344+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
2013-07-23T17:16:01.446344+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 347, in url_patterns
2013-07-23T17:16:01.446691+00:00 app[web.1]: File "/app/noticeboard/models.py", line 2, in <module>
2013-07-23T17:16:01.446691+00:00 app[web.1]: from django_extensions.db.fields import AutoSlugField
2013-07-23T17:16:01.446344+00:00 app[web.1]: self._urlconf_module = import_module(self.urlconf_name)
2013-07-23T17:16:01.446344+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2013-07-23T17:16:01.446344+00:00 app[web.1]: __import__(name)
2013-07-23T17:16:01.446344+00:00 app[web.1]: File "/app/listing/urls.py", line 3, in <module>
2013-07-23T17:16:01.446344+00:00 app[web.1]: from noticeboard import views
2013-07-23T17:16:01.446691+00:00 app[web.1]: File "/app/noticeboard/views.py", line 2, in <module>
2013-07-23T17:16:01.446691+00:00 app[web.1]: from noticeboard.models import Listings
2013-07-23T17:16:01.446691+00:00 app[web.1]: ImportError: No module named django_extensions.db.fields
2013-07-23T17:16:01.611717+00:00 app[web.1]: Traceback (most recent call last):
2013-07-23T17:16:01.615024+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=thawing-wildwood-4650.herokuapp.com fwd="79.121.160.251" dyno=web.1 connect=3ms service=175ms status=500 bytes=135
2013-07-23T17:16:01.611717+00:00 app[web.1]: 2013-07-23 12:16:01 [7] [ERROR] Error handling request
2013-07-23T17:16:01.611717+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-07-23T17:16:01.611963+00:00 app[web.1]: return debug.technical_500_response(request, *exc_info)
2013-07-23T17:16:01.611963+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/views/debug.py", line 69, in technical_500_response
2013-07-23T17:16:01.611963+00:00 app[web.1]: html = reporter.get_traceback_html()
2013-07-23T17:16:01.611963+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/views/debug.py", line 298, in get_traceback_html
2013-07-23T17:16:01.611717+00:00 app[web.1]: return self.application(environ, start_response)
2013-07-23T17:16:01.611717+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/dj_static.py", line 59, in __call__
2013-07-23T17:16:01.611717+00:00 app[web.1]: response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2013-07-23T17:16:01.611717+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
2013-07-23T17:16:01.611717+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
2013-07-23T17:16:01.611717+00:00 app[web.1]: response = self.get_response(request)
2013-07-23T17:16:01.611963+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in handle_uncaught_exception
2013-07-23T17:16:01.611717+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 126, in handle_request
2013-07-23T17:16:01.612261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 74, in render_node
2013-07-23T17:16:01.611963+00:00 app[web.1]: return t.render(c)
2013-07-23T17:16:01.611963+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 140, in render
2013-07-23T17:16:01.611963+00:00 app[web.1]: return self._render(context)
2013-07-23T17:16:01.611963+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 134, in _render
2013-07-23T17:16:01.612261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 830, in render
2013-07-23T17:16:01.612261+00:00 app[web.1]: bit = self.render_node(node, context)
2013-07-23T17:16:01.611963+00:00 app[web.1]: return self.nodelist.render(context)
2013-07-23T17:16:01.612261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/defaultfilters.py", line 715, in date
2013-07-23T17:16:01.612261+00:00 app[web.1]: return format(value, arg)
2013-07-23T17:16:01.612987+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/dateformat.py", line 312, in format
2013-07-23T17:16:01.612261+00:00 app[web.1]: return node.render(context)
2013-07-23T17:16:01.612261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/debug.py", line 84, in render
2013-07-23T17:16:01.612987+00:00 app[web.1]: pieces.append(force_text(getattr(self, piece)()))
2013-07-23T17:16:01.612987+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/dateformat.py", line 216, in r
2013-07-23T17:16:01.612987+00:00 app[web.1]: return self.format('D, j M Y H:i:s O')
2013-07-23T17:16:01.612261+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 606, in resolve
2013-07-23T17:16:01.612261+00:00 app[web.1]: new_obj = func(obj, *arg_vals)
2013-07-23T17:16:01.612987+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/encoding.py", line 99, in force_text
2013-07-23T17:16:01.613230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 71, in ugettext
2013-07-23T17:16:01.613230+00:00 app[web.1]: return _trans.ugettext(message)
2013-07-23T17:16:01.613230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 276, in ugettext
2013-07-23T17:16:01.613230+00:00 app[web.1]: return do_translate(message, 'ugettext')
2013-07-23T17:16:01.612987+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2013-07-23T17:16:01.612987+00:00 app[web.1]: return df.format(format_string)
2013-07-23T17:16:01.612987+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/dateformat.py", line 35, in format
2013-07-23T17:16:01.612987+00:00 app[web.1]: pieces.append(force_text(getattr(self, piece)()))
2013-07-23T17:16:01.612987+00:00 app[web.1]: s = s.__unicode__()
2013-07-23T17:16:01.613230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/functional.py", line 130, in __text_cast
2013-07-23T17:16:01.613230+00:00 app[web.1]: return func(*self.__args, **self.__kw)
2013-07-23T17:16:01.613230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 258, in do_translate
2013-07-23T17:16:01.613230+00:00 app[web.1]: _default = translation(settings.LANGUAGE_CODE)
2013-07-23T17:16:01.613230+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 172, in translation
2013-07-23T17:16:01.613230+00:00 app[web.1]: default_translation = _fetch(settings.LANGUAGE_CODE)
2013-07-23T17:16:01.613573+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 154, in _fetch
2013-07-23T17:16:01.613573+00:00 app[web.1]: app = import_module(appname)
2013-07-23T17:16:01.613573+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
2013-07-23T17:16:01.613573+00:00 app[web.1]: __import__(name)
2013-07-23T17:16:01.613573+00:00 app[web.1]: ImportError: No module named south
2013-07-23T17:16:01.612261+00:00 app[web.1]: output = self.filter_expression.resolve(context)
2013-07-23T17:16:01.142419+00:00 heroku[router]: at=info method=GET path=/ host=thawing-wildwood-4650.herokuapp.com fwd="79.121.160.251" dyno=web.1 connect=2ms service=246ms status=500 bytes=135
(venv)suraj-kapoors-computer:listing surajkapoor$

最佳答案

Auto Deploy 目前已关闭。
您可以从文本文件创建命令(批处理)文件:将 .txt 更改为 .cmd 然后添加:

call heroku login
call git add .
call git commit -am "changethisnumbereachadd3.2"
call git push heroku master

I do this for Laravel's production:

call npx mix
call php artisan config:cache
call composer install --optimize-autoloader --no-dev
call npx mix --production
call heroku login
call git add .
call git commit -am "changes3.2"
call git push heroku master
将文件拖放到 vscode 命令终端,或 cd 到您的代码。
将其改编为 Django 产品。
这将绕过他们此时遇到的内部服务器错误。
你还需要cli:
https://devcenter.heroku.com/articles/heroku-cli

关于django - "Internal Server Error"将 Django 应用程序部署到 Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17814307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com