【问题标题】:Deploying Django Project on Pythonanywhere在 Pythonanywhere 上部署 Django 项目
【发布时间】:2020-12-05 19:05:59
【问题描述】:

我将在本地计算机上运行良好的应用程序上传到 pythonanywhere。我让它工作,但不是显示我网站的主页,而是显示“它有效,欢迎使用 Django”页面。有人可以帮我吗?

这是我的 wsgi 文件

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vorakor.settings')

application = get_wsgi_application()

这是我的 settings.py 文件

INSTALLED_APPS = [
    'website',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
]

 TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['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',
            ],
        },
    },
]

【问题讨论】:

  • 我建议你在 Heroku 上部署这个项目,因为它是免费的,而且比 pythonanywhere 更灵活。

标签: python-3.x django


【解决方案1】:

您是否转移了整个本地项目?我建议将您的整个项目上传到您的远程 Github 存储库,然后通过 git pull 从 pythonanywhere 机器上提取它。还要确保在远程机器上的虚拟环境中安装了所有工具。 我能想到的另一件事是,settings.py 文件找不到您的模板目录。确保将其复制到与本地计算机相同的位置。

【讨论】:

    猜你喜欢
    • 2021-07-02
    • 2015-04-23
    • 2016-09-05
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 2016-10-01
    相关资源
    最近更新 更多