views.py
class citydetailview(generic.ListView):
model = country
def get_queryset(self):
city_type = self.kwargs['city_type']
if city_type == 1:
mytypes=city1.objects.all()
ads=test1_ads.objects.all()
context={'ads':ads,'mytypes':mytypes}
return context
elif city_type == 2:
mytypes=city2.objects.all()
ads=test2_ads.objects.all()
context={'ads':ads,'mytypes':mytypes}
return context
elif city_type == 3:
mytypes=city3.objects.all()
ads=test3_ads.objects.all()
context={'ads':ads,'mytypes':mytypes}
return context
return super().get_queryset()
我正在尝试呈现来自model:country和查询集中条件上下文的输出。而且我正在尝试如何为该类视图设计模板。
这样做需要您的帮助:)