Browse Source

Django example: Celery app defined in projects main reusable app instead of a separate tasks django app

Ask Solem 11 years ago
parent
commit
5c50200df8

+ 6 - 6
examples/django/README.rst

@@ -10,13 +10,13 @@ Contents
 
 This is the project iself, created using
 ``django-admin.py startproject proj``, and then the settings module
-(``proj/settings.py``) was modified to add ``tasks`` and ``demoapp`` to
+(``proj/settings.py``) was modified to add ``demoapp`` to
 ``INSTALLED_APPS``
 
-``tasks/``
+``proj/celery.py``
 ----------
 
-This app contains the Celery application instance for this project,
+This module contains the Celery application instance for this project,
 we take configuration from Django settings and use ``autodiscover_tasks`` to
 find task modules inside all packages listed in ``INSTALLED_APPS``.
 
@@ -24,8 +24,8 @@ find task modules inside all packages listed in ``INSTALLED_APPS``.
 ------------
 
 Example generic app.  This is decoupled from the rest of the project by using
-the ``@shared_task`` decorator.  Shared tasks are shared between all Celery
-instances.
+the ``@shared_task`` decorator.  This decorator returns a proxy that always
+points to the currently active Celery instance.
 
 
 Starting the worker
@@ -36,4 +36,4 @@ worker:
 
 .. code-block:: bash
 
-    $ DJANGO_SETTINGS_MODULE='proj.settings' celery -A tasks worker -l info
+    $ DJANGO_SETTINGS_MODULE='proj.settings' celery -A proj worker -l info

+ 0 - 0
examples/django/tasks/__init__.py → examples/django/proj/celery.py


+ 0 - 3
examples/django/tasks/models.py

@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.

+ 0 - 16
examples/django/tasks/tests.py

@@ -1,16 +0,0 @@
-"""
-This file demonstrates writing tests using the unittest module. These will pass
-when you run "manage.py test".
-
-Replace this with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-
-class SimpleTest(TestCase):
-    def test_basic_addition(self):
-        """
-        Tests that 1 + 1 always equals 2.
-        """
-        self.assertEqual(1 + 1, 2)

+ 0 - 1
examples/django/tasks/views.py

@@ -1 +0,0 @@
-# Create your views here.