0

I have a web app on Django platform.

I have a method within views.py:

def task():
    print("my task")

how can I run it every day once?

I need a very simple solution and it should be independent of other tasks (parallel).

Nesi
  • 19
  • 5

1 Answers1

1

There are several libraries that help facilitate periodic tasks. Two that I have used are celery and django-q.

Celery is a general python task manager. Using it with django requires additional libraries to bring them together. Where as django-q is specifically for django projects.

On a side note, if the task() function is not an actual view, then it belongs in a separate file other than views.py.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • is there another simpler solution? Celery is too complex for a simple task – Nesi Aug 11 '21 at 18:17
  • django-q. it doesn't get any simpler – Rob Vezina Aug 11 '21 at 18:29
  • @NasimiEldarov Django-Q is less complex than celery in my experience, but I find it's documentation less robust, especially in the introduction/overview area. As an aside, the complexity of the task is entirely independent of the complexity of scheduling it to run. – Code-Apprentice Aug 11 '21 at 20:40