django-background-tasks icon indicating copy to clipboard operation
django-background-tasks copied to clipboard

manage.py process_tasks not picking tasks w Django 3.2

Open whwkong opened this issue 4 years ago • 2 comments

I've been using django-background-tasks since Django 2.0, no problem.

Even with Django 3.1, no problem (this article for 3.1 explains all the necessary steps quite well)

Recently I migrated to Python 3.8.5 and Django 3.2 (I'm using Ubuntu 20.0.4). However, with Django 3.2's automatic AppConfig discovery, I was forced to make some changes to get background-tasks working.

I've also had to make similar changes to other third-party apps such as django-allauth to get them to work with Django 3.2 and so far, I haven't had issues with them yet.


I set DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField".

Secondly, I added in myproject/apps.py file:

from background_task.apps import BackgroundTasksAppConfig

class ModifiedBackgroundTasksConfig(BackgroundTasksAppConfig):
    default_auto_field = "django.db.models.AutoField"

and modified my INSTALLED_APPS:

INSTALLED_APPS = [
  # ..etc..
  # "background_task", 
  myproject.app.ModifiedBackgroundTasksConfig,
]

When I schedule tasks and run manage.py process_tasks in a terminal, nothing gets picked up.

Does anyone else have this issue?

whwkong avatar Oct 02 '21 16:10 whwkong

@whwkong Did you got the solution for this ? If yes please post the solution for this i am also getting the same issue

s-nikhil-lilly avatar Jan 20 '22 19:01 s-nikhil-lilly

@whwkong @s-nikhil-lilly got the same problem. Found a workaround by setting BACKGROUND_TASK_RUN_ASYNC = False in Django settings.

https://github.com/arteria/django-background-tasks/blob/e04d44c07110443bbdeb8cb14effbe497ddbb98d/background_task/models.py#L56

alexandrenorman avatar Oct 16 '23 18:10 alexandrenorman