Я пытаюсь получить данные из базы данных Neo4j в шаблоне Django через Neomodel.
Вот пример информации, которую я имею в Neo4j:
![Neo4j sample for SKINCLAS CodeList](https://i.stack.imgur.com/Cy00m.png)
Итак, вот мой model.py:
from django.db import models
from django.utils import timezone
from neomodel import (config, install_all_labels, StructuredNode, StructuredRel, StringProperty, IntegerProperty, UniqueIdProperty, Relationship, RelationshipTo, RelationshipFrom, DateProperty)
config.DATABASE_URL = 'bolt://neo4j:mypassword@localhost:7687'
class CodeListRelation(StructuredRel):
From = IntegerProperty()
To = IntegerProperty()
class CodeList(StructuredNode):
OID = StringProperty(unique_index=True)
Name = StringProperty()
EnumeratedItems = RelationshipTo('EnumeratedItem', 'Has_EnumeratedItem', model = CodeListRelation)
class EnumeratedItem(StructuredNode):
CodedValue = StringProperty()
nciodm_ExtCodeID = StringProperty()
CodeLists = RelationshipFrom(CodeList, 'Has_EnumeratedItem', model = CodeListRelation)
Тогда в моем файле view.py у меня есть следующее:
from django.shortcuts import render
def get_codelists(request):
local_codelist = CodeList.nodes.order_by('nciodm_CDISCSubmissionValue')
context = {'codelists': local_codelist}
return render(request, 'lgcdfn/codelists.html', context)
И вотмой HTML-файл (называемый здесь codelist.html):
{% for codelist in codelists %}
<br><a id="{{ codelist.Name }}"></a>
<div>
<table>
<caption><span>{{ codelist.Name }}</span></caption>
<tr class="header">
<th scope="col">Ext Code ID</th>
<th scope="col">Coded Value</th>
<th scope="col">Validity dates</th>
</tr>
{% for enumerateditem in codelist.EnumeratedItems %}
<tr>
<td>{{ enumerateditem.nciodm_ExtCodeID }}</td>
<td>{{ enumerateditem.CodedValue }}</td>
<td>From: {{ enumerateditem.CodeLists.From }}<br/>To: {{ enumerateditem.CodeLists.To }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endfor %}
Итак, со следующим кодом я получаю следующую HTML-страницу:
![Screen Copy of the result for SKINCLAS](https://i.stack.imgur.com/6qOS8.png)
Итак, мой вопрос здесь: - Как я могу заказать EnumeratedItem на основе CodedValue (здесь вызывается enumerateditem.CodedValue)?- Почему я не получаю даты действия (здесь вызывается enumerateditem.CodeLists.From и enumerateditem.CodeLists.To, которые хранятся в отношениях под Neo4j)?
Заранее благодарю за помощь.