Skip to content

Commit

Permalink
TaskCommand.run_task() now returns the ID of the created Task
Browse files Browse the repository at this point in the history
  • Loading branch information
morlandi committed Dec 31, 2021
1 parent 01f17fa commit f851e69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
History
=======

2.0.5
-----
* TaskCommand.run_task() now returns the ID of the created Task

2.0.4
-----
* TaskCommand.run_task() now returns the created Task
Expand Down
4 changes: 2 additions & 2 deletions django_task/task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run_task(self, TaskClass, created_by=None, **options):
# use it to set task verbosity;
# otherwise, keep the default value suggested by the task Model
if 'task_verbosity' in param_names:
if '-v' in sys.argv or '--verbosity' in sys.argv:
if ('-v' in sys.argv or '--verbosity' in sys.argv) and 'verbosity' in options:
options['task_verbosity'] = options['verbosity']

params = dict([item for item in options.items() if item[0] in param_names])
Expand All @@ -43,5 +43,5 @@ def run_task(self, TaskClass, created_by=None, **options):
raise CommandError('[%s] ERROR: %s' % (timezone.now().isoformat(), str(e)))

self.stdout.write('[%s] %s scheduled (task=%s)' % (timezone.now().isoformat(), TaskClass.__name__, str(task.id)))
return task
return task.id if task is not None else None

0 comments on commit f851e69

Please sign in to comment.