我在引導樹中顯示了一些模型。現在我必須在引導列表中顯示該樹的特定節點的詳細信息。我知道我需要爲此使用AJAX視圖。但我沒有明確的想法。請幫幫我。Django Bootstrap列表
以下是我的觀點
def get_context_data(self, **kwargs):
context = dict()
organization = Organization.objects.all()
orglocations = Orglocations.objects.all()
locationprocessarea = Locationprocessarea.objects.all()
processareaasset = Processareaasset.objects.all()
processtaglink = Processareaassettaglink.objects.all()
context["TreeStructure"] = [
{
'text': organizations.name,
'nodes': [
{
'text': orglocationss.name,
'nodes': [
{
'text': processarea.name,
'nodes': [
{
'text': processasset.name,
'nodes':[{
'text':processareafilter.name,
'nodes':[{
'text':taglink.name
}for taglink in processtaglink.filter(areaassetid=processareafilter.id)]
}for processareafilter in processareaasset.filter(parentassetid=processasset.id)]
} for processasset in processareaasset.filter(processareaid=processarea.id).filter(parentassetid__isnull=True)]
} for processarea in locationprocessarea.filter(locationid=orglocationss.id)]
} for orglocationss in orglocations.filter(organizationid_id=organizations.id)]
} for organizations in organization.filter(id=1)]
return {
"tree_view": context
}
,我已經在我的模板使用的是腳本,
<script>
var test_tree = {{ tree_view.TreeStructure | safe }};
$('#tree').treeview({data: test_tree});
</script>
請幫我.. !!在此先感謝
嘗試'var test_tree =「{{tree_view.TreeStructure | safe}}」;' – itzMEonTV
@itzmeontv其顯示錯誤 – priya