DJANGO celery task is executed from shell but it's not executed from view
Question: I am trying to create some asynchronous tasks with celery in my django
application

settings.py

    
    
    BROKER_URL = 'django://localhost:6379/0'
    CELERY_ACCEPT_CONTENT = ['json']
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_RESULT_SERIALIZER = 'json'
    

celery.py:

    
    
    from __future__ import absolute_import
    import os
    from celery import Celery
    from django.conf import settings
    
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'provcon.settings')
    
    app = Celery('provcon')
    app.config_from_object('django.conf:settings')
    app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
    

project __init__py:

    
    
    from __future__ import absolute_import
    from .celery import app as celery_app
    

tasks.py:

    
    
    from __future__ import absolute_import
    from celery import shared_task
    from celery import task
    from .models import Proc_Carga
    @task()
    def carga_ftp():
        tabla = Proc_Carga()
        sp = tabla.carga()
    
        return None
    

I call the asysnchronous tasks from my view like this:

    
    
    from .tasks import carga_ftp
    
    @login_required(login_url='/login/')
    def archivoview(request):
        usuario= request.user
        if request.method == 'POST':
           form = ProcFTPForm(usuario,request.POST)
           if form.is_valid():
              form.save()
              proc = Lista_Final()
              lista = proc.archivos()
              # call asynchronous task 
              carga_ftp.delay()
              return HttpResponseRedirect('/resumen/')
        else:
          form = ProcFTPForm(usuario)
        return render_to_response('archivo.html',{'form':form},context_instance=RequestContext(request))
    

When I run the task from the python manage.py shell. The worker is executed
and create the database objects without any problem

but when I try to execute the task from the view, doesn't work is not executed

Any idea why the task run from the manage.py shell but not from the views

Thanks in advance


Answer: Check if redis is running

    
    
    $redis-cli ping
    

Check if the celery worker is running in the django admin interface

If not running execute this command

    
    
    celery -A provcon worker -l info
    

Test your task from your django application

If works run the celery worker in background like a
[daemon](http://celery.readthedocs.org/en/latest/tutorials/daemonizing.html)

