I am not sure why this template does not display anything on the page. Is there something obvious I'm missing here?
View:
@user_passes_test(is_staff) def details_activity_log(request, project_id, template='projects/details_activity_log.html'): project = get_object_or_404(Project.objects.select_related(), pk=project_id) action_log = project.projectactionlog_set.all() log_group = defaultdict(list) for log in action_log: log_group[log.action_time.strftime('%y%m%d')].append(log)
log_group contains such type of model objects as:
defaultdict(<type 'list'>, {'110614': [<ProjectActionLog: ProjectActionLog object>, ...]})
Template:
{% for key, log in log_group %} {% for action in log %} {{ action }} {{ action.action_time }} {{ action.user.first_name }} {{ action.message }} {{ action.object_name }} {% endfor %} {% endfor %}
Edit If I only looked in the docs, I would see the answer. https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for
However, this is a difficult situation, because the templates do not throw any errors at runtime when the loop cannot unpack the iterator elements.
source share