mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 22:28:11 +08:00
docs: added section about scheduling management commands
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
Schedules
|
Schedules
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Schedule
|
||||||
|
--------
|
||||||
|
|
||||||
Schedules are regular Django models. You can manage them through the :ref:`admin_page` or directly from your code with the :func:`schedule` function or the :class:`Schedule` model:
|
Schedules are regular Django models. You can manage them through the :ref:`admin_page` or directly from your code with the :func:`schedule` function or the :class:`Schedule` model:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
@@ -22,6 +25,26 @@ Schedules are regular Django models. You can manage them through the :ref:`admin
|
|||||||
schedule_type=Schedule.DAILY
|
schedule_type=Schedule.DAILY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Management Commands
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
If you want to schedule regular Django management commands, you can use the :mod:`django.core.management` module to make a wrapper function which you can schedule in Django Q::
|
||||||
|
|
||||||
|
# tasks.py
|
||||||
|
from django.core import management
|
||||||
|
|
||||||
|
# wrapping `manage.py clearsessions`
|
||||||
|
def clear_sessions_command():
|
||||||
|
return management.call_command('clearsessions')
|
||||||
|
|
||||||
|
# now you can schedule it to run every hour
|
||||||
|
from django_q import schedule
|
||||||
|
|
||||||
|
schedule('tasks.clear_sessions_command', schedule_type='H')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference
|
Reference
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user