Je suivais ce tutorielexemple échantillon de django-céleri ne fonctionne pas dans l'application Django
http://celeryq.org/docs/django-celery/getting-started/first-steps-with-django.html
Je DDEBUT le céleri avec
python manage.py celeryd
Alors je l'ai fait tasks.py
dans myapp
dossier avec
from celery.decorators import task
@task()
def add(x, y):
return x + y
Puis-je mettre ces derniers dans settings.py
import djcelery
djcelery.setup_loader()
CELERY_RESULT_BACKEND = "database"
CELERY_RESULT_DBURI = "mysql://user1:[email protected]/ajfdfa_rabbitmq"
BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"
Puis j'ai commencé le shell python avec
python manage.py shell
Puis type i
des tâches d'importation myapp
Il est allé ok
Mais quand je tape le nom de la fonction alors j'obtiens l'erreur
add.delay(4, 4)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'add' is not defined
Ce que je suis absent
merci mon pote, j'allais quittez mais vous m'avez sauvé – user825904
@ user825904 pas de problème, content que je puisse vous aider. –
Pour moi, task.add (4, 4) renvoie NameError .... tasks.add (4, 4) l'a résolu. – user1881957