Skip to content

Installation

Requirements

  • Python 3.8+
  • Django 3.2+

Install the Package

pip install django-simple-queue

Configure Django

1. Add to INSTALLED_APPS

Add django_simple_queue to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    # Django apps...
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # Third-party apps...
    'django_simple_queue',

    # Your apps...
    'myapp',
]

2. Add URL Configuration

Include the task status URL in your urls.py:

from django.urls import path, include

urlpatterns = [
    # ...
    path('django_simple_queue/', include('django_simple_queue.urls')),
]

3. Run Migrations

Apply the database migrations to create the Task table:

python manage.py migrate django_simple_queue

Start the Worker

Run the worker command to start processing tasks:

python manage.py task_worker

Running in Production

In production, use a process manager like systemd, supervisor, or Docker to keep the worker running. You can run multiple workers for parallel processing.

Verify Installation

  1. Create a simple task function:

    # myapp/tasks.py
    def hello_world(name):
        return f"Hello, {name}!"
    
  2. Enqueue a task from Django shell:

    from django_simple_queue.utils import create_task
    
    task_id = create_task(
        task="myapp.tasks.hello_world",
        args={"name": "World"}
    )
    print(f"Created task: {task_id}")
    
  3. Check the task status at /django_simple_queue/task?task_id=<task_id> or in the Django admin.

Next Steps