I have 2 lists:
year_month_day_list = ['2017-02-12', '2017-02-11', '2017-02-10', '2017-02-09']
filename_prefix_list = ['2017-02-12_11-45-59', '2017-02-12_11-35-05', '2017-02-10_11-00-52', '2017-02-11_10-59-23', '2017-02-09_09-12-09']
If I can grab all of the filenames that match their associated ymd:
def filter_files(file_list, filter_param):
return [f for f in file_list
if f.startswith(filter_param)]
for unique_day in year_month_day_list:
files_for_day = sorted(filter_files(
filename_prefix_list, unique_day), reverse=True)
How can I create a dictionary that uses the unique_day as the key and the associated filenames for that day as the values?
Output should be something like:
dict = {'2017-02-12': ['2017-02-12_11-45-59', '2017-02-12_11-35-05'], '2017-02-10': ['2017-02-10_11-00-52']}
Then, how can I use those in my template? Something like:
<div class="thumbnail-row" id="thumbnail_row">
<div class="row-date">
<span>{{ unique_day }}</span>
</div>
<div class="">
<form action="{{ filename_prefix }}/video/" method="post">
{% csrf_token %}
<input type="image" name="filename_prefix" value="{{ filename_prefix }}" src="{{ MEDIA_URL}}thumbnails/2017/02/{{ filename_prefix }}.jpg">
</form>
</div>
</div>