#Problem with Django-q2 ValueError function is not defined (but it is)
9 messages · Page 1 of 1 (latest)
Can you please share the full stack trace as well as the relevant code?
this is in myapp/tasks.py
def hola_mundo(): print("Hola Mundo") return "Hola Mundo"
`# myapp/schedulers/scheduler.py
from django_q.models import Schedule
def schedule_hello_world():
Schedule.objects.create(
func='myapp.tasks.hola_mundo',
schedule_type=Schedule.MINUTES,
minutes=5,
repeats=-1
)
`
and this is the error
`
13:45:28 [Q] ERROR Failed 'myapp.tasks.hola_mundo' (echo-jig-quebec-diet) - Function myapp.tasks.hola_mundo is not defined : Traceback (most recent call last):
File "C:\route\project\venv\Lib\site-packages\django_q\worker.py", line 96, in worker
raise ValueError(f"Function {task['func']} is not defined")
ValueError: Function myapp.tasks.hola_mundo is not defined
`
im calling that scheduled in app.py in this way:
`
from django.apps import AppConfig
class MyAppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'myapp'
def ready(self):
from .schedulers.scheduler import schedule_hello_world
schedule_hello_world()
`
Your app config shows the app name as myapp whereas the error shows conector_biloop_bitrix as being the app name.
sorry it was me renaming the functions to share it
just in case Im still having the issue 🙂