Django上下文未在基本模板中呈现

时间:2020-02-07 15:15:09

标签: django

我很高兴以前曾经问过类似的问题,但是看了之后,我似乎仍然无法解决我的问题。

根据文档,我具有以下文件:

views.py

from django.shortcuts import render


# Create your views here.

def base(request):
    articles = 'articles'
    dboard = 'dashboard'
    pages = {'dboard':dboard, 'Articles':articles}
    return render(request, 'collatedata/base.html', pages)


def dash(request):
    return render(request, 'collatedata/dash.html')

collat​​edata / urls.py:

urlpatterns = [
    path('', views.dash, name='dash'),
]

主要urls.py:

urlpatterns = [
    path('', include('collatedata.urls')),
    path('admin/', admin.site.urls),
]

base.html:

...

              <li class="nav-item">
                <a href="#" class="nav-link text-white p-3 mb-2">
                  <i class="fas fa-home text-light fa-lg mr-3"></i>
                  {{ dboard }}
                </a>
              </li>

...

dash.html

{% extends "./base.html" %}

但是,输出不会读取{{dboard}}

因此返回此:

              <li class="nav-item">
                <a href="#" class="nav-link text-white p-3 mb-2">
                  <i class="fas fa-home text-light fa-lg mr-3"></i>

                </a>
              </li>

与扩展base.html有关吗?

0 个答案:

没有答案