Reputation: 53
I have created tasks.py in my app. Celery tasks I have created can be called in cmd or inside tasks.py itself. But it is not possible to call them in views.py or models.py.
Upvotes: 0
Views: 32
Reputation: 2243
Where you file at? it should be inside your django project to be use.
If you place it in some folder keep in mind to make one file __init__.py
so django can see that folder as part of the project
project
- app1
- - __init__.py
- - models.py
- - admin.py
- - ...
- app2
- - __init__.py
- - models.py
- - admin.py
- - ...
- tasks
- - __init__.py
- - my_task_file.py
Or you can use as command line:
import os
os.system('<code to call your script>');
Upvotes: 1