[Django]-Access django celery results in views

5๐Ÿ‘

โœ…

As celery_results_taskresults use a model to store results, so we can use them in the views. You can try like this:

from django_celery_results.models import TaskResult


class SomeTemplateView(TemplateView):

     def get_context_data(self, *args, **kwargs):
         context = super(SomeTemplateView, self).get_context_data(*args, **kwargs)    
         context['results'] = TaskResult.objects.all()
         return context

And in the template:

{% for r in results %}
      {{r.task_name}}
      ...
{% endfor %}
๐Ÿ‘คruddra

Leave a comment