代码之家  ›  专栏  ›  技术社区  ›  jianbo jia

当使用django_表2时,它告诉我TemplateDoesNotExist

  •  3
  • jianbo jia  · 技术社区  · 7 年前

    URL。py公司

    urlpatterns = [
    
        url(r'^admin/', admin.site.urls),
        url(r'^$', views.people),
    ]
    

    def people(request):
    
        return render(request, 'people.html', {'people': models.Person.objects.all()})
    

    模型。py公司

    class Person(models.Model):
    
        name = CharField(verbose_name="full name", max_length=10)
    

    {% load render_table from django_tables2 %}
    {% load static %}
    
    {% render_table people %}
    

    当我运行它时,它告诉我 TemplateDoesNotExist at /django_tables2/table.html ,我不明白为什么。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Alasdair    7 年前

    首先,确保 django_tables2 包含在您的 INSTALLED_APPS

    然后,确保你有 APP_DIRS 设置为 True TEMPLATES 背景

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [...],
            'APP_DIRS': True,
            ...
        },
    ]