0

I want to run a function after django server has started. Now, that function should run after all the views and URLs are initialized because the function might make requests to one of the registered routes.

Shubh Parmar
  • 27
  • 2
  • 6

1 Answers1

0

Let's assume you want to call scrape() function from task.py.

You can call the function in urls.py like this:

from django.urls import path
from .task import scrape

urlpatterns = [
    ...
]

scrape()

You can also use threading here if you encounter any problem.

Mhasan502
  • 73
  • 8