docs: added section about scheduling management commands

This commit is contained in:
Ilan Steemers
2015-07-10 17:36:18 +02:00
parent 2c58262b17
commit 13bbf3dcc4
+23
View File
@@ -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
--------- ---------