複数のモデルから情報をレンダリングする必要があるテンプレートがあります。このような私のmodels.py見て何か:複数モデルのDjangoテンプレート
# models.py
from django.db import models
class foo(models.Model):
''' Foo content '''
class bar(models.Model):
''' Bar content '''
私も、私はthis Django documentationとthe answer given hereに応じて書いて、そこからファイルviews.pyを、持っている、そしてこのようなものになります。
# views.py
from django.views.generic import ListView
from app.models import *
class MyView(ListView):
context_object_name = 'name'
template_name = 'page/path.html'
queryset = foo.objects.all()
def get_context_data(self, **kwargs):
context = super(MyView, self).get_context_data(**kwargs)
context['bar'] = bar.objects.all()
return context
と私をurls.pyのurlpatternsは以下の目的を持っている:
url(r'^path$',views.MyView.as_view(), name = 'name'),
私の質問はどのように私はFからのオブジェクトとオブジェクトのプロパティを参照することができるテンプレートページ/ path.htmlに、あります私のページにそれらを表示するには?最も簡単な例については