**我创建了这个,但是当我尝试运行服务器时,它只显示 django 网站。我已将其关闭,因为防火墙也不是问题。**from django.contrib import adminfrom django.urls import pathfrom django.http import HttpResponsedef home(request): return HttpResponse('home')def contact(request): return HttpResponse('contact')urlpatterns = [ path('admin/', admin.site.urls), path('', home), path('about/', contact),]**I also added it to apps**INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'accounts',]
1 回答
慕容森
TA贡献1853条经验 获得超18个赞
考虑到您的项目名称是project,应用程序名称是app
在你的项目目录中,
project/urls.py
from .app import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home),
path('about/', views.contact),
]
app/views.py
def home(request):
return HttpResponse('home')
def contact(request):
return HttpResponse('contact')
添加回答
举报
0/150
提交
取消