0
私のコンピュータ上でrunserverを起動した後、最初にページを読み込むと、オブジェクトデータがそこにあります(下の例では3つのリンク)。オブジェクトをリロードすると、データはそこに存在しなくなります(下の例ではリンクがゼロになります)。ページを更新するとdjangoオブジェクトのデータが消えます
テンプレート
{% for url in urls %}
<a href="{{ url }}">
link
</a>
{% endfor %}
ビュー
class IntroView(View):
template_name = '[app_name]/template.html'
model_names = ['shoe', 'hat', 'bag']
urls = [reverse_lazy('%s:%s' % ('[app_name]', name)) for name in model_names]
dict_to_template = {'urls': urls}
def get(self, request, *args, **kwargs):
return render(request, self.template_name, context=self.dict_to_template)
これはおそらく、本当に簡単なものだが、それは私を持っています。
ありがとうございます。