Simple Django & celery Integration
Project description
Django Tasks Manager
Just a Simple Django & Celery integration.
How to use it
👉 Install the package via
PIP
$ pip install django-tasks-manager
// OR
$ pip install git+https://github.com/app-generator/django-tasks-manager.git
👉
Add new routing
# core/settings.py
urlpatterns = [
...
path("", include("django_tm.urls")), # <-- New Routes
...
]
👉 Cretae
Scrips & LOGS
directory - The Recomended place is in the root of the project:
$ mkdir celery_scripts # Used in Settings -> CELERY_SCRIPTS_DIR
$ mkdir celery_logs # Used in Settings -> CELERY_SCRIPTS_DIR
- Make sure the user that executes the app has write permission.
- Copy the sample scripts in the scripts directory.
- All scripts will be available in the UI, ready to be executed by the manager.
👉
Update Configuration
: Include the new APPS
INSTALLED_APPS = [
...
'django_tm', # Django Tasks Manager # <-- NEW
'django_celery_results', # Django Celery Results # <-- NEW
]
👉
Update Configuration
: Include the new templates
TEMPLATE_DIR_TASKS = os.path.join(BASE_DIR, "django_tm/templates") # <-- NEW
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATE_DIR, TEMPLATE_DIR_TASKS], # <-- Updated
'APP_DIRS': True,
},
]
👉
Update Configuration
: New CELERY_ Section
#############################################################
# Celery configurations
# https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html
# Working Directories required write permission
CELERY_SCRIPTS_DIR = os.path.join(BASE_DIR, "celery_scripts" )
CELERY_LOGS_DIR = os.path.join(BASE_DIR, "celery_logs" )
CELERY_BROKER_URL = os.environ.get("CELERY_BROKER", "redis://localhost:6379")
CELERY_RESULT_BACKEND = os.environ.get("CELERY_BROKER", "redis://localhost:6379")
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT = 30 * 60
CELERY_CACHE_BACKEND = "django-cache"
CELERY_RESULT_BACKEND = "django-db"
CELERY_RESULT_EXTENDED = True
CELERY_RESULT_EXPIRES = 60*60*24*30 # Results expire after 1 month
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
#############################################################
#############################################################
👉
Start the App
$ # Set up the database
$ python manage.py makemigrations
$ python manage.py migrate
$
$ # Create the superuser
$ python manage.py createsuperuser
$
$ # Start the application (development mode)
$ python manage.py runserver # default port 8000
Access the Tasks
page: http://127.0.0.1:8000/tasks
👉 Start the Celery Manager (another terminal)
Note:
Redis
server is expected on port6379
(default)
$ celery --app=django_tm.celery.app worker --loglevel=info
Screenshots
@Todo
Django Tasks Manager - Open-source library provided by AppSeed
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-tasks-manager-0.0.1.tar.gz
(12.0 kB
view hashes)
Close
Hashes for django-tasks-manager-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9fc605963532dfcb261f12d149e8feb7c2757dede265ccfd2758be642d98631 |
|
MD5 | 4e1e98d56b7cd2993fea2f27f06481a7 |
|
BLAKE2b-256 | 8007e558bc80e9f84779b7465fac2d98bf527b13ac46e795923fa7cca2a8f5b1 |