我正在開發第一次使用Django應用程序。我怎麼能傳遞多個模型模板Django將多個模型傳遞給模板
views.py
from django.views.generic import ListView, DetailView
from django.utils import timezone
from LastAlly.models import Article, Episode
class IndexView(ListView):
queryset = Article.objects.all().order_by("-date")[:3]
template_name = 'index.html'
urls.py
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import ListView, DetailView
from LastAlly.views import IndexView
urlpatterns = [
url(r'^$', IndexView.as_view(),),
]
「將多個模型傳遞給模板」是什麼意思? – Gocht
我需要使用Episode模型來索引模板。 – Crownstyle