[英]ModuleNotFoundError: No module named 'my_app.urls' in django
after deploying site on heroku,it's showing Internal server error.在 heroku 上部署站点后,它显示内部服务器错误。 for debug I made "debug=true" and I found this error:
对于调试,我做了“debug=true”,我发现了这个错误:
"ModuleNotFoundError: No module named 'my_app.urls' "
I've added my app in installed app list我已将我的应用添加到已安装应用列表中
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'my_app',
]
my_project urls:我的项目网址:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('my_app.urls'))
]
my_app urls: my_app 网址:
from django.urls import path
from . import views
urlpatterns = [
path('',views.home ),
]
views.py:视图.py:
from django.shortcuts import render
def home(request):
return render(request,'index.html')
site running on local server while debug = true
but not running while debug=false
(showing server error )站点在本地服务器上运行,而
debug = true
但在debug=false
时未运行(显示服务器错误)
so how to fix this error "ModuleNotFoundError: No module named 'my_app.urls' "那么如何解决这个错误“ModuleNotFoundError: No module named 'my_app.urls'”
What did I miss.我错过了什么。 Any help/suggestion will be highly appreciated.
任何帮助/建议将不胜感激。 Thanks
谢谢
you have to include your app information inside of your installed app section您必须在已安装的应用部分中包含您的应用信息
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'my_app.apps.YOURAPPCONFIG NAME',
]
YOURAPPCONFIG NAME is in your apps.py, and copy the name of class and paste it. YOURAPPCONFIG NAME 在你的 apps.py 中,复制 class 的名称并粘贴。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.