【发布时间】:2014-01-17 05:18:38
【问题描述】:
我正在编写我的第一个 Django 网站。 我想将数据从我的视图传递到我的模板。
我的看法:
from django.views import generic
class AboutView(generic.TemplateView):
template_name = 'about.html'
def get_context_data(self, **kwargs):
ctx = super(AboutView,self).get_context_data(**kwargs)
ctx['test'] = 'This testtext should be displayed in the Webpage'
return ctx
我的模板:
{% extends 'site_base.html' %}
{% block body %}
{% endblock %}
如何在正文块中显示测试文本?
【问题讨论】:
-
这个问题似乎离题了,因为它是关于入门教程中很好地涵盖的一个基本问题。
标签: django django-templates django-class-based-views