因此,我在本地计算机上构建了一个Django应用程序,该应用程序运行良好。使用Bitvise,我已将文件复制到服务器上,并尝试从那里运行服务器。一切似乎运行良好,我可以访问管理页面,但是,无法访问主页。当我尝试访问我添加的任何URL时,在尝试列出的URL中,列出的唯一一个是“ ^ admin”。
以下是主应用程序的urls.py:
from django.conf.urls import url, include
from django.urls import path
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
path('home/', include('Home.urls', namespace='Home')),
path('billing/', include('billing.urls', namespace='billing')),
path('createquote/', include('createquote.urls', namespace='createquote')),
path('accounts/', include('django.contrib.auth.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
以下是我的settings.py中已安装的应用程序:
INSTALLED_APPS = [
'Home',
'billing',
'createquote',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
还有我的ROOT_URLCONF:
ROOT_URLCONF = 'LNQuoteTool.urls'
错误:
Using the URLconf defined in project01.urls, Django tried these URL patterns, in this order:
admin/
The current path, home/, didn't match any of these.
应注意,这是一个404错误。
有什么明显的错误吗?我该怎么解决?
答案 0 :(得分:0)
事实证明,此问题的解决方法是使用IP地址0.0.0.0:8000/运行服务器。以下是使我能够从其他设备连接到它的确切命令:
python manage.py runserver 0.0.0.0:8000/
我希望我能提供更好的解释,因为我不清楚其背后的原因(也许0表示正在使用计算机的IP地址)。感谢所有试图帮助我解决此问题的人。