|
1 | | -# sample-django-tasks-manager |
| 1 | +# Django Tasks Manager - `How to use it` |
| 2 | + |
| 3 | +This repository provides a `step-by-step` integration of Django Tasks Manager, an open-source Python library built on top of Celery. In the end, the `superusers` are able to manage tasks (create, revoke) and visualize the output and runtime logs - The product is actively supported by [AppSeed. |
| 4 | + |
| 5 | +> Features |
| 6 | +
|
| 7 | +- ✅ Create/Revoke Celery Tasks |
| 8 | +- ✅ View LOGS & Output |
| 9 | +- ✅ Minimal Configuration |
| 10 | +- ✅ Installation via PyPi |
| 11 | +- ✅ Available [TASKS](https://github.com/app-generator/django-tasks-manager/blob/main/django_tm/tasks.py) (provided as starting samples) |
| 12 | + - `users_in_db()` - List all registered users |
| 13 | + - `execute_script()` - let users execute the [scripts](https://github.com/app-generator/django-tasks-manager/tree/main/django_tm/celery_scripts) defined in `CELERY_SCRIPTS_DIR` (configuration parameter) |
| 14 | + |
| 15 | +<br /> |
| 16 | + |
| 17 | +@todo |
| 18 | + |
| 19 | +<br /> |
| 20 | + |
| 21 | +## Project Creation - `v0.0.1` tag |
| 22 | + |
| 23 | +In this phase only the basic files are provided: |
| 24 | + |
| 25 | +- `README.md` |
| 26 | +- `CHANGELOG.md` |
| 27 | +- `.gitignore` |
| 28 | + |
| 29 | +Besides the files, the Virtual environment is created: |
| 30 | + |
| 31 | +```bash |
| 32 | +$ python3 -m venv env # create virtual environment |
| 33 | +$ source env/bin/activate # actvate the VENV |
| 34 | +$ pip install --upgrade pip # update PIP |
| 35 | +``` |
| 36 | + |
| 37 | +<br /> |
| 38 | + |
| 39 | +## Create the Django Project - `v0.0.2` tag |
| 40 | + |
| 41 | +In this phase, the usual commands are used: |
| 42 | + |
| 43 | +```bash |
| 44 | +$ pip install Django # Install Django |
| 45 | +$ django-admin startproject core . # create 'core' project |
| 46 | +$ python manage.py migrate # migrate DB |
| 47 | +$ python manage.py runserver # Access the basic app in the browser |
| 48 | +``` |
| 49 | + |
| 50 | +<br /> |
| 51 | + |
| 52 | +## Install Django TM Package - `v0.0.3` tag |
| 53 | + |
| 54 | +The new is installed and the related directories are created: |
| 55 | + |
| 56 | +```bash |
| 57 | +$ pip install django-tasks-manager # install the package |
| 58 | +$ mkdir celery_logs # here the logs are saved |
| 59 | +$ mkdir celery_scripts # scripts to be executed |
| 60 | +``` |
| 61 | + |
| 62 | +The sample scripts are provided by the package for a fast start: |
| 63 | +https://github.com/app-generator/django-tasks-manager/tree/main/django_tm/celery_scripts |
| 64 | + |
| 65 | + |
| 66 | +<br /> |
| 67 | + |
| 68 | +## Install Django TM Package - `v0.0.4` tag |
| 69 | + |
| 70 | +Update configuration and routing. Here are the impacted files: |
| 71 | + |
| 72 | +- `core/settings.py` |
| 73 | +- `core/urls.py` |
| 74 | + |
| 75 | +<br /> |
| 76 | + |
| 77 | +## Final set up & Usage - `v1.0.0` tag |
| 78 | + |
| 79 | +In this phase the project becomes usable. The database is migrated and a superuser is created to access and manage the tasks. |
| 80 | + |
| 81 | +```bash |
| 82 | +$ python manage.py makemigrations # generate the new SQL |
| 83 | +$ python manage.py migrate # migrate (update) DB |
| 84 | +$ |
| 85 | +$ python manage.py createsuperuser # create the app user |
| 86 | +$ |
| 87 | +$ # Start the application |
| 88 | +$ python manage.py runserver |
| 89 | +``` |
| 90 | + |
| 91 | +> Note: The `celery` task manager should be started using a different terminal |
| 92 | +
|
| 93 | +```bash |
| 94 | +$ celery --app=django_tm.celery.app worker --loglevel=info |
| 95 | +``` |
| 96 | + |
| 97 | +Once the superuser is authenticated, the tasks manager should be usable: |
| 98 | + |
| 99 | +> `http://127.0.0.1:8000/tasks` |
| 100 | +
|
0 commit comments