django-user-tasks

raw JSON →
4.0.0 verified Fri May 01 auth: no python

Management of user-triggered asynchronous tasks in Django projects. Integrates with Celery and Django REST Framework to track task status and results. Current version: 4.0.0, released 2025. Monthly releases.

pip install django-user-tasks
error ModuleNotFoundError: No module named 'django_user_tasks'
cause Package not installed or not added to INSTALLED_APPS.
fix
Run pip install django-user-tasks and add 'django_user_tasks' to INSTALLED_APPS in settings.py.
error AttributeError: module 'django_user_tasks' has no attribute 'create_user_task'
cause Incorrect import path; the function is in models, not top-level.
fix
Use from django_user_tasks.models import create_user_task.
error django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured.
cause Trying to use django-user-tasks outside of a Django project (e.g., standalone script).
fix
Set up Django settings before using the library, e.g., os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings').
breaking In v4.0.0, Celery protocol v2 headers changed. The 'id' parameter name was updated. If you use custom Celery task headers, verify your code.
fix Update any code that reads or sets task headers to use the new 'id' key.
deprecated The function `get_storage` has been deprecated in Django 5.2. In v3.4.1, a fix was applied; but if you call `get_storage` directly, update to Django's new storage API.
fix Use Django's `storages` module instead of `django.core.files.storage.get_storage`.
gotcha `create_user_task` is not in the `tasks` module. Many users import it incorrectly as `from django_user_tasks.tasks import create_user_task`.
fix Import from `django_user_tasks.models`.
pip install django-user-tasks[cors]

Create a user task that runs asynchronously. Requires Celery configured.

from django_user_tasks.models import create_user_task

# Create a user task and trigger a Celery task
def my_view(request):
    user = request.user
    task_type = 'export'
    task_kwargs = {'param1': 'value'}
    user_task = create_user_task(user, task_type, task_kwargs)
    return user_task.state  # e.g., 'PENDING'