from django.shortcuts import render from django.views.generic import ListView from .models import Specialization class SpecListView(ListView): model = Specialization def get_context_data(self, **kwargs): context = super(SpecListView, self).get_context_data(**kwargs) root = Specialization.objects.get(pk=1) context['root'] = root context['children'] = root.get_children() context['roots'] = Specialization.objects.root_nodes() return context