Skip to content

Commit

Permalink
docs: updated management command example
Browse files Browse the repository at this point in the history
  • Loading branch information
Koed00 committed Sep 26, 2015
1 parent 7847e3b commit 6c81840
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions docs/examples.rst
Expand Up @@ -227,6 +227,22 @@ In Python 3.5 the subprocess module has changed quite a bit and returns a :class
Instead of :func:`async` you can of course also use :func:`schedule` to schedule commands.

For regular Django management commands, it is easier to call them directly:

.. code-block:: python
from django_q.tasks import async, schedule
async('django.core.management.call_command','clearsessions')
# or clear those sessions every hour
schedule('django.core.management.call_command',
'clearsessions',
schedule_type='H')
Groups
======
A group example with Kernel density estimation for probability density functions using the Parzen-window technique.
Expand Down
15 changes: 14 additions & 1 deletion docs/schedules.rst
Expand Up @@ -57,7 +57,20 @@ The scheduler will then skip execution of scheduled events in the past. Instead
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::
If you want to schedule regular Django management commands, you can use the :mod:`django.core.management` module to call them directly:

.. code-block:: python
from django_q.tasks import schedule
# run `manage.py clearsession` every hour
schedule('django.core.management.call_command',
'clearsessions',
schedule_type='H')
Or you can make a wrapper function which you can then schedule in Django Q:

.. code-block:: python
# tasks.py
from django.core import management
Expand Down

0 comments on commit 6c81840

Please sign in to comment.