5

My problem ought to be fairly simple and is more a question of interest than something that needs to be desperately fixed. Google could not give me the answer I was looking for so I hope your expertise can help me out. I am using:

Django 1.4
Celery 2.5.5
Redis 2.4.10 (latest version on homebrew?)

And I am running everything using the follwing commands:

redis-server /usr/local/etc/redis.conf
foreman run python manage.py runserver
foreman run "python manage.py celeryd -E -B --loglevel=INFO"
foreman run python manage.py celerycam

In my settings.py I have the following configuration set for Celery:

import djcelery
djcelery.setup_loader()

BROKER_URL = redis
CELERY_RESULT_BACKEND = 'redis'
CELERY_REDIS_HOST = "localhost"
CELERY_REDIS_PORT = 6379
CELERY_REDIS_DB = 0

CELERY_SEND_TASK_ERROR_EMAILS = True
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERY_TASK_RESULT_EXPIRES = 172800  # 48 hours.

With this configuration it all seems to be working, except one thing:

With django-celery you automatically get celery integration in the django admin (neat!), you can check the status of all your tasks that are not expired and schedule new tasks etc.

In the task list in the admin, no values are displayed, meaning all the values are None. when I click on a value i can see the details however so it does look like they are being collected correctly. It is just a detail but it annoys me alot.

What could be the reason that it is not displaying those values in the list and what could I do to fix it?

Thanks in advance

Edit: screenshots

So here are some screenshots, as you can see all the values like uuid etc. are None but it does see wether the task has finished or not. In the second screenshot you can see the detail page (after you click on a task) and here it has all the info.

The django-celery admin task list not displaying all values And the second image:

The detail page of a task displaying all values

Allard Stijnman
  • 1,284
  • 11
  • 22
  • What do you mean with "In the task list in the admin, no values are displayed, meaning all the values are None": do you see tasks with states (such as STARTED, SUCCESS, FAILURE)? If so, that means celerycam is working properly. What values are you talking about? – Simeon Visser Jun 19 '12 at 09:46
  • please see the images i added to the post – Allard Stijnman Jun 19 '12 at 11:37

2 Answers2

2

I have this as well. It appears to be a bug in django-celery. You should update your version of django-celery if you want this to be fixed (it has been fixed in this commit in django-celery).

If you change the following (at djcelery.admin_utils in the function fixedwidth):

return """<span title="%s", style="font-size: %spt;\
                font-family: Menlo, Courier; ">%s</span>""" % (
    escape(val[:255]), pt, escape(shortval)).replace("|br/|", "<br/>")

into:

    return ("""<span title="%s", style="font-size: %spt;\
                    font-family: Menlo, Courier; ">%s</span>""" % (
        escape(val[:255]), pt, escape(shortval))).replace("|br/|", "<br/>")

then the values do appear in the admin.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
  • Unfortunately that will not be an option since heroku doesn't allow this, and to git clone instead of pip install for something this simple won't do either. Hope the 2.6 release will be stable soon! – Allard Stijnman Jun 19 '12 at 12:04
  • You can monkeypatch the code though to make it work in the current version. – Simeon Visser Jun 19 '12 at 12:19
1

I had the same error too. The example given about updating the admin_utils.py has a slight error though! The replacements you need to make are :

Add FIXEDWIDTH_STYLE at the top of admin_utils.py:

FIXEDWIDTH_STYLE = '''\
<span title="%s", style="font-size: %spt; \
font-family: Menlo, Courier; ">%s</span> \
'''

And then replace :

return """<span title="%s", style="font-size: %spt;\
                font-family: Menlo, Courier; ">%s</span>""" % (
    escape(val[:255]), pt, escape(shortval)).replace("|br/|", "<br/>")

With :

styled = FIXEDWIDTH_STYLE % (escape(val[:255]), pt,escape(shortval))
return styled.replace("|br/|", "<br/>")

You can see it more clearly in the github link above. Works perfect! Cheers!

Jamie Owen
  • 36
  • 2