djangoテンプレートでpython viewメソッドres()を呼び出そうとしていますが、呼び出されません。view.pyのPythonメソッドがdjangoテンプレートを呼び出さない
これは私がカウントをインクリメントしようとすると、以降のレベルの後に0にリセットしかし、そのリセット方法は、Djangoのテンプレートからの呼び出しを取得していないのです、私の見る
class make_incrementor(object):
def __init__(self, start):
self.count=start
def __call__(self, jump=1):
self.count += jump
return self.count
@property
def res(self):
self.count =0
return self.count
def EditSchemeDefinition(request, scheme_id):
iterator_subtopic = make_incrementor(0)
scheme_recs = scheme.objects.get(id=scheme_id)
view_val = {
'iterator_subtopic': iterator_subtopic,
"scheme_recs": scheme_recs,
}
return render(request, "edit.html", view_val)
です。
これは
<td id="subTopic" class="subTopic">
{% for strand in scheme_recs.stand_ids.all %}
{{ iterator_subtopic.res }}
{% for sub_strand in strand.sub_strand_ids.all %}
{% for topic in sub_strand.topic_ids.all %}
{% for subtopic in topic.sub_topic_ids.all %}
<input id="subTopic{{ iterator_subtopic }}" class="len"
value="{{ subtopic.name }}">
<br>
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
</td>
私の{{iterator_subtopic.res}}私のedit.htmlページでは、コールを取得していないとiterator_subtopicの値が再び0にセットされますされていません。 Functionとその呼び出しはTerminal上で正常に動作していますが、djangoテンプレートでは描画されません。
私が間違っている箇所を修正してください。 ありがとうございます。