1👍
news_list[monthyear] = {'Year': year, 'Month' : month}
The datastructure returned by build_news_archive
is an object. When iterating over an object in python (and django templates) the keys are iterated over by default
<ol class="list-unstyled">
{% for monthyear, archive in newsarchive.items %}
<li>{{ archive.year }} + {{ archive.month }}</li>
{% endfor %}
</ol>
you can call python items
dict method in django template by accessing your_dict.items
in a for loop
https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for
0👍
What happens when you try to do this? The one thing I noticed is that you are referring to the dictionary keys ‘Year’ and ‘Month’ as ‘year’ and ‘month’ (noticed the difference in case of the first letter). The template is processed on the server side and hence should be case-sensitive.
Other than that, dm03514’s suggestion is should be incorporated as well.
- Is it possible to automatically inject the request into model methods?
- Django path to uploaded image
0👍
Try this might help
return render(request, 'en/public/news.html', locals())
<ol class="list-unstyled">
{% for archive in rDict.newsarchive %}
<li>{{ archive.year }} + {{ archive.month }}</li>
{% endfor %}
</ol>
- Can we get request parameters from Django settings or other variables?
- Django-simple-menu integration with bootstrap
- Missing something with autentication in django?
- Is it normal that the Django site I recently deployed on Apache is always on?
- Django-registration email domain whitelist