我是 Django 的新手,所以这可能是一个简单的错误。我创建了一个项目并添加了一些单独的应用程序。一切似乎都在本地运行,但是一旦我将其部署到 Heroku,就会出现以下错误:No module named 'myapp.api.urls'
项目结构:
website
|____myapp
| |_____api
| | |_____urls.py
| | |_____views.py
| |
| |_____homepage
| | |_____urls.py
| | |_____views.py
| |
| |_____mailing
| | |_____urls.py
| | |_____views.py
| |
| |_____settings.py
| |_____urls.py
| |_____wsgi.py
|
|_____manage.py
|_____Procfile
|_____requirements.txt
|_____runtime.txt
简介:
web: gunicorn myapp.wsgi --log-file -
settings.py(不是整个文件内容):
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ALLOWED_HOSTS = ['127.0.0.1', 'myapp.herokuapp.com']
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp.api',
'myapp.homepage',
'myapp.mailing',
]
ROOT_URLCONF = 'myapp.urls'
WSGI_APPLICATION = 'myapp.wsgi.application'
API 网址模式:
urlpatterns = [
path('account/register/', ApiAccountRegisterView.as_view()),
path('account/login/', ApiAccountLoginView.as_view()),
]
MyApp 网址模式:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('myapp.api.urls')),
path('', include('myapp.homepage.urls'))
]
知道我做错了什么吗?我在网上搜索过,但找不到任何东西可以帮助我解决这个问题。任何帮助,将不胜感激!
四季花海
慕娘9325324
相关分类