首页 > 解决方案 > Django 1.11:尚未加载应用程序

问题描述

我正在学习如何使用 Django 框架进行 Web 编程,当我尝试返回模板时收到此错误消息。当我尝试加载https://www..../index2/时,一切正常。

这是我的 urls.py:

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^index2/$', views.index2, name='index2'),
]

这是我的views.py:

from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.

def index(request): 
    return render(request, 'main/index.html',)

def index2(request):
    return HttpResponse("Hello, world.")

标签: pythondjango

解决方案


如果您启用了调试模式,请确保您已index.html保存。app/templates/main/index.html异常页面将显示与pathsdjango 尝试加载的位置不同index.html


推荐阅读