**我創(chuàng)建了這個(gè),但是當(dāng)我嘗試運(yùn)行服務(wù)器時(shí),它只顯示 django 網(wǎng)站。我已將其關(guān)閉,因?yàn)榉阑饓σ膊皇菃?wèn)題。**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貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊
考慮到您的項(xiàng)目名稱是project,應(yīng)用程序名稱是app
在你的項(xiàng)目目錄中,
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')
添加回答
舉報(bào)
0/150
提交
取消