Fetching contributors…
Cannot retrieve contributors at this time
82 lines (57 sloc) 2.46 KB
Frequently Asked Questions
Generating a template in a task doesn't seem to respect my i18n settings?
**Answer**: To enable the Django translation machinery you need to activate
it with a language. **Note**: Be sure to reset to the previous language when
>>> from django.utils import translation
>>> prev_language = translation.get_language()
>>> translation.activate(language)
>>> try:
... render_template()
... finally:
The common pattern here would be for the task to take a ``language``
.. code-block:: python
from celery.decorators import task
from django.utils import translation
from django.template.loader import render_to_string
def generate_report(template="report.html", language=None):
prev_language = translation.get_language()
language and translation.activate(language)
report = render_to_string(template)
The celery test-suite is failing
**Answer**: If you're running tests from your Django project, and the celery
test suite is failing in that context, then follow the steps below. If the
celery tests are failing in another context, please report an issue to our
issue tracker at GitHub:
That Django is running tests for all applications in ``INSTALLED_APPS``
by default is a pet peeve for many. You should use a test runner that either
1) Explicitly lists the apps you want to run tests for, or
2) Make a test runner that skips tests for apps you don't want to run.
For example the test runner that celery is using:
To use this test runner, add the following to your ````:
.. code-block:: python
TEST_RUNNER = "djcelery.tests.runners.CeleryTestSuiteRunner",
Or, if you just want to skip the celery tests:
.. code-block:: python
TEST_RUNNER = "djcelery.tests.runners.CeleryTestSuiteRunner",
TEST_APPS = filter(lambda k: k != "celery", INSTALLED_APPS)