python 无法打开文件 'manage.py' - "heroku run python manage.py migrate command input"

python cant open file 'manage.py' - "heroku run python manage.py migrate command input"

您好,我已经完成了我的 Django pycharm 项目,现在我正在尝试将它上传到 heroku/在 heroku 上托管它。我遵循了这个 link https://medium.com/@qazi/how-to-deploy-a-django-app-to-heroku-in-2018-the-easy-way-48a528d97f9c ,它在过去实际上对我有用。当我到达步骤时,您是否输入了此命令,但是 'heroku run python manage.py migrate' 我继续收到此错误消息 '运行 python manage.py 在 ⬢ radiant-retreat-19016 上迁移。 ..向上,运行.6371(免费) python: 无法打开文件 'manage.py': [Errno 2] 没有那个文件或目录' 我不是初学者,所以我知道我的 manage.py 文件在正确的位置,特别是因为我可以 运行 ' python manage.py 运行server ' .我会将代码连同我的 manage.py 代码和设置一起附加到下面的 procFile 中。我在互联网上到处寻找这个问题,有些人遇到了这个问题,但对他们没有任何帮助。如果您需要,我会附上任何其他代码。我什至将所有代码转移到一个新项目中,也出现了同样的问题。

web: gunicorn inspect_list2.wsgi






#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'inspect_list2.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()






"""
Django settings for inspect_list project.

Generated by 'django-admin startproject' using Django 2.2.14.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os
import django_heroku

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'not showing this but its there'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'my_app',
    #'auth',

]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'inspect_list2.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR,],
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'inspect_list2.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

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

AUTH_USER_MODEL = 'my_app.CustomUser'

LOGIN_REDIRECT_URL = 'front_page'
LOGOUT_REDIRECT_URL = 'home'

django_heroku.settings(locals())

10个小时后我终于弄明白了。其他在线来源是正确的。如果您参考我在上面最底部命令中发布的 link 。如果您 运行 git 先推送东西而不是最后一个命令,然后 运行 heroku migrate 命令它应该可以工作。等待!如果它不起作用,那么如果您触摸了 git 存储库的东西或更改了名称或弄乱了您的 squilte3 文件并且您不知道自己在做什么然后将所有代码转移到另一个项目所以 git 东西和 squilte3 东西自动制作并重置,然后再次按照此评论中的说明进行操作。如果不是,我不知道该告诉你什么,但这对我有用。

已修复

heroku run python **FOLDER**/manage.py migrate

heroku run python HOME/manage.py migrate