在django app

时间:2017-10-29 14:05:50

标签: html django

更新的django ...我正在尝试在我的django应用程序中新的html页面,它似乎没有呈现。我收到了404错误。

Output of 404 error

我已经使用这种方法成功添加了其他页面,但由于某种原因它不再起作用了。

我采取的步骤:

  1. 信息中心/模板文件夹
  2. 中添加了新的html文件
  3. views.py
  4. 中添加了新课程
  5. 将新课程导入 urls.py 并添加到 urlpatterns
  6. 故障排除:

    1. 我重新启动了Apache
    2. views.py

      from django.http import HttpResponse
      from django.conf import settings
      from django.views.generic import View
      from django.shortcuts import render
      from django.contrib.auth.models import User
      #from Minerva.backend.backend import CustomLDAPAuthBackend
      from django.contrib.auth.backends import RemoteUserBackend
      
      import logging
      
      #logger = logging.getLogger(__name__)
      
      
      ## Main Dashboard page
      class DashboardsView(View):
      
          def get(self, request):      
              return render(request, "Dashboards.html")
      
      ## Documentation
      class DocumentationView(View):
      
          def get(self, request):
              return render(request, "Documentation.html")
      

      urls.py

      from django.conf.urls import url
      from Dashboards.views import DashboardsView
      from Dashboards.views import AmbulatoryQualityView, CancerCenterView, DecisionSupportView
      from Dashboards.views import EnterpriseQualityView, HumanResourcesView, IPAnalyticsView, ManagedCareView, DocumentationView
      from django.views.generic import TemplateView
      
      app_name = 'Dashboards'
      
      urlpatterns = [
          url(r'^$', DashboardsView.as_view(), name='Dashboards'),
          url(r'^/Ambulatory Quality$', AmbulatoryQualityView.as_view()),
          url(r'^/Cancer Center Service Line$', CancerCenterView.as_view()),
          url(r'^/Decision Support$', DecisionSupportView.as_view()),
          url(r'^/Enterprise Quality$', EnterpriseQualityView.as_view()),
          url(r'^/Human Resources$', HumanResourcesView.as_view()),
          url(r'^/IP_Analytics$', IPAnalyticsView.as_view()),
          url(r'^/Managed Care$', ManagedCareView.as_view()),
          url(r'^/Documentation$', DocumentationView.as_view()),
      ]
      

1 个答案:

答案 0 :(得分:0)

它与你的urlpatterns中没有任何关系,首先r^/Documentations$应该是r^Documentation/$,不要在你的URL中使用大写字母,不要在你使用空格时想要长网址,r'^/Cancer Center Service Line$'将为r'^cancer-center-service-line/$',等等。