Package: django-celery-async-view
Asynchronously load view or download file in django.
This is done by rendering view or creating file in celery task and polling it in javascript.DocumentationThe full documentation is athttps://django_celery_async_view.readthedocs.io.QuickstartInstall django_celery_async_view:pip install django_celery_async_viewAdd it to yourINSTALLED_APPS:INSTALLED_APPS=(...'django_celery_async_view',...)FeaturesThis package includes two separate features: AsyncView and AsyncDownload.AsyncViewexample_app.views.pyclassExampleView(AsyncDownloadView):task=example_view_taskexample_app.tasks.py@shared_taskdefexample_view_task(user_id):returnAsyncViewReturnHTML().run(user_id=user_id,html_string=create_html_example(...))example_download_page.html<!-- jQuery before django_celery_async_view --><scripttype="text/javascript"src="{% static "path/to/jquery.js"%}"></script><scripttype="text/javascript"src="{% static "django_celery_async_view/django_celery_async_view.js"%}"></script><script>vartask_id='{{task_id}}';varpoll_interval=10000;AsyncViews.initAsyncView(poll_interval,task_id);</script>AsyncDownloadexample_app.views.pyclassExampleDownloadView(AsyncDownloadView):task=my_download_taskexample_async_page.html<scriptsrc="{% static "django_celery_async_view/django_celery_async_view.js"%}"></script><script>$(document).ready(function(){varpoll_interval=5*1000;// 5svartask_id='{{task_id}}';AsyncViews.initAsyncView(poll_interval,task_id);});</script>example_app.tasks.py@shared_taskdefexample_download_task(*args,**kwargs):returnMyDownloadCreateFile().run(*args,**kwargs)classExampleDownloadCreateFile(AbstractAsyncDownloadCreateFile):defcreate_file(self,some_arg):# do stuff to create:# file_content, filename, mimetypereturnfile_content,filename,mimetypeexample_download_page.html<!-- jQuery before django_celery_async_view --><scripttype="text/javascript"src="{% static "path/to/jquery.js"%}"></script><scripttype="text/javascript"src="{% static "django_celery_async_view/django_celery_async_view.js"%}"></script><button>DOWNLOAD</button><buttonclass="async-download-button"data-href="/example-download/"data-poll-interval="5000">Async Download</button>Configurationssettings.pyASYNC_VIEW_TEMP_FILE_DURATION_MS=10*60*1000# 10minRunning Example ProjectRequires redis.
Does not require postgres (tests require postgres)# setup
# install redis
cd example
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate

# run:
# run redis (if not running)
celery worker -A example
python manage.py runserverRunning TestsTests are run against example project?
Tests require postgres andenv var POSTGRES_PASSWORD setor no postgres server authenticationvirtualenv venv
source venv/bin/activate
(myenv) $ pip install tox
(myenv) $ toxDevelopmentWhat needs to be fixed for Python3 supportcopy celerytest project and set celerytest.__init__ imports to absolutecelerytest.__init__.py:1: in <module>
from config import CELERY_TEST_CONFIG, CELERY_TEST_CONFIG_MEMORY
ImportError: No module named 'config'AsyncResult(task_id).wait(timeout=5, interval=0.5) and possibly result.get() will break.example\example\tests\test_async_views.py:50: in phase3
example_view_task.AsyncResult(task_id).wait(timeout=5, interval=0.5)

    if meta:
            self._maybe_set_cache(meta)
            status = meta['status']
            if status in PROPAGATE_STATES and propagate:
>               raise meta['result']
E               TypeError: exceptions must derive from BaseException

celery\result.py:175: TypeErrorCreditsTools used in rendering this package:Cookiecuttercookiecutter-djangopackageHistory0.1.0 (2017-11-14)First release on PyPI.