1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| 404err:http://127.0.0.1:8000/index 1.设置views from django.shortcuts import render
# Create your views here. from django.views.generic import View
class ArticleView(View): def get(self,request): return render(request,'index.html') 2.设置setting TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] 3.设置urls urlpatterns = [ path('admin/', admin.site.urls), path('', ArticleView.as_view(),name='index'), ]
|