對於以下URL路由爲blog應用, from django.conf.urls import url, include
from django.views.generic import ListView, DetailView
from blog.models import Post
urlpatterns=[
url(r'^$', ListView.as_view(
我想顯示根據條件不同的模板: class RouteList(ListView):
model = DailyRoute
template_name = 'route_list.html'
def get_queryset(self):
if DailyRoute.objects.filter(stage = '1').exists():
我想對模型執行行級數學並將結果顯示在模板中。該數據庫每天爲每家公司提供一行。 class MyModel(models.Model):
company = model.CharField(...
daily_target = model.PositiveSmallIntger(...
actual = model.PositiveSmallIntger(...