Forwarded from Bobosher Musurmonov
Class-based(generic) viewlarda bu ishni
get_context_data() methodi bajaradi. Default holda bu yerda faqat get_queryset() methodi qaytargan queryset bo'ladi. Qo'shimcha context qo'shish uchun methodni override qilish kerak:posts = Post.objects.all()
authors = Author.objects.all()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["authors"] = authors
context["posts"] = posts
return contextTemplateda
{{posts}}, {{authors}} ko'rinishida ishlataverasiz.