pythad pythad - 13 days ago 5
Python Question

What is the right place to initialize third-party API in Django project for later Celery use

I have a twitter API used in my Django project.

Right now I keep initialization in my

settings.py
and in
tasks.py
I just import API from
django.conf.settings
. I am not sure if it's a good practice as I've never seen it. Do I need to create API instance somewhere in
celery.py
or even in the task function?

Answer

With Celery better in the task function