Browse Source

Merge pull request #2928 from wyc/master

Update Django Example and README
Ask Solem Hoel 9 years ago
parent
commit
17c9d27114

+ 24 - 0
examples/django/README.rst

@@ -27,6 +27,19 @@ Example generic app.  This is decoupled from the rest of the project by using
 the ``@shared_task`` decorator.  This decorator returns a proxy that always
 points to the currently active Celery instance.
 
+Installing requirements
+=======================
+
+The settings file assumes that ``rabbitmq-server`` is running on ``localhost``
+using the default ports. More information here:
+
+http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html
+
+In addition, some Python requirements must also be satisfied:
+
+.. code-block:: bash
+
+    $ pip install -r requirements.txt
 
 Starting the worker
 ===================
@@ -34,3 +47,14 @@ Starting the worker
 .. code-block:: bash
 
     $ celery -A proj worker -l info
+
+Running a task
+===================
+
+.. code-block:: bash
+    
+    $ python ./manage.sh shell
+    >>> from demoapp.tasks import add, mul, xsum
+    >>> res = add.delay(2,3)
+    >>> res.get()
+    5

+ 2 - 0
examples/django/proj/celery.py

@@ -7,6 +7,8 @@ from celery import Celery
 # set the default Django settings module for the 'celery' program.
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
 
+from django.conf import settings  # noqa
+
 app = Celery('proj')
 
 # Using a string here means the worker will not have to

+ 1 - 0
examples/django/proj/settings.py

@@ -11,6 +11,7 @@ CELERY_BROKER_URL = 'amqp://guest:guest@localhost//'
 #: Only add pickle to this list if your broker is secured
 #: from unwanted access (see userguide/security.html)
 CELERY_ACCEPT_CONTENT = ['json']
+CELERY_RESULT_BACKEND = 'db+sqlite:///results.sqlite'
 
 # Django settings for proj project.
 

+ 2 - 0
examples/django/requirements.txt

@@ -0,0 +1,2 @@
+django==1.8.4
+sqlalchemy==1.0.9