Python 如何修复[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json';德扬戈

Python 如何修复[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json';德扬戈,python,django,web,Python,Django,Web,我正在尝试将project manager应用程序部署到heroku。它正在本地运行。 我正在按照教程部署我的应用程序。我不知道错误在哪里,也不知道如何修复,希望你能帮助我。 NotADirectoryError位于/,表示[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json' 以下是我的一些后端代码: MIDDLEWARE = [ 'whitenoise.middleware.Whi

我正在尝试将project manager应用程序部署到heroku。它正在本地运行。 我正在按照教程部署我的应用程序。我不知道错误在哪里,也不知道如何修复,希望你能帮助我。
NotADirectoryError位于/
,表示
[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json'

以下是我的一些后端代码:

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    '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',
]

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
PROJECT_ROOT   =   os.path.join(os.path.abspath(__file__))
STATIC_ROOT  =   os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'

# Extra lookup directories for collectstatic to find static files
STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT, 'static'),
)

#  Add configuration for static files storage using whitenoise
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

import dj_database_url 
prod_db  =  dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(prod_db)
我无法成功链接到静态文件。 这是我的html模板代码的错误部分: 模板呈现期间出现错误

<link
    rel="stylesheet"
    type="text/css"
    href="{% static 'projectManager/style.css' %}"
  />
My models.py:

class Project(models.Model):
    title = models.CharField(max_length=100)
    date = models.DateTimeField(auto_now_add=timezone.now())

    def __str__(self):
        return self.title
[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json'

罪魁祸首是:

PROJECT_ROOT = os.path.join(os.path.abspath(__file__))
# That means:
#     PROJECT_ROOT = '/app/myProjectManager/settings.py/'
# And:
#     STATIC_ROOT: '/app/myProjectManager/settings.py/staticfiles/'
# which is incorrect

如果
staticfiles
app
中,则将其更改为:

PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# That means:
#     PROJECT_ROOT: '/app/'
# And:
#     STATIC_ROOT: '/app/staticfiles/'
# Which is correct.

您需要根据
设置的位置更新
PROJECT\u ROOT
。与项目的根目录相比,py
位于哪个位置。

[Errno 20]不是目录:'/app/myProjectManager/settings.py/staticfiles/staticfiles.json'

罪魁祸首是:

PROJECT_ROOT = os.path.join(os.path.abspath(__file__))
# That means:
#     PROJECT_ROOT = '/app/myProjectManager/settings.py/'
# And:
#     STATIC_ROOT: '/app/myProjectManager/settings.py/staticfiles/'
# which is incorrect

如果
staticfiles
app
中,则将其更改为:

PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# That means:
#     PROJECT_ROOT: '/app/'
# And:
#     STATIC_ROOT: '/app/staticfiles/'
# Which is correct.

您需要根据
设置的位置更新
PROJECT\u ROOT
。与项目的根目录相比,py
位于哪个位置。