Why not create a celery target model and save the celery task id for this model?
class CeleryModel(models.Model): celery_task_id = models.CharField(max_length = 50, unique=True)
Then:
def some_celery_task(): result = celery_task.delay() celery_task = CeleryModel(celery_task_id = result.id) celery_task.save()
Then your integer value will be as follows: celery_task.id to match the actual unique celery_task_id.
UPDATE: another way ...
First python manage.py inspectdb > inspectdb.py . Inside this file you will find:
class CeleryTaskmeta(models.Model): id = models.IntegerField(primary_key=True) task_id = models.CharField(max_length=765, unique=True) status = models.CharField(max_length=150) result = models.TextField(blank=True) date_done = models.DateTimeField() traceback = models.TextField(blank=True) hidden = models.IntegerField() meta = models.TextField(blank=True) class Meta: db_table = u'celery_taskmeta'
Next, python manage.py startapp celery_model . Place this file in the models.py file. I use south, so my last step will be python manage.py convert_app celery_model . However, this is not necessary. Now you have django level access to this celery dataset, and you can read the primary key for each task as an integer value. for instance
>>> ct = CeleryTaskmeta.objects.get(id=1) >>> for k,v in ct.__dict__.items(): print k,v ... status SUCCESS task_id 2fa95f24-7640-434c-9fef-0732ac1d23c7 date_done 2013-02-17 19:22:56+00:00 traceback None _state <django.db.models.base.ModelState object at 0x10263fa90> meta eJxrYKotZAzlSM7IzEkpSs0rZIotZC7WAwBREgb9 result gAJLBC4= hidden 0 id 1
Someone smart would know how to make your CeleryTaskmeta model read-only, because I don't think you want to interfere with the datatable.
UPDATE: to the last part of your question:
>>> from celerytest.tasks import add >>> result = add.delay() >>> result.int_id = 1 >>> for k,v in result.__dict__.items(): print k,v ... parent None app <Celery default:0x10264df10> task_name celerytest.tasks.add int_id 1 id 01503afd-d196-47af-8e10-e7dc06603cfc backend <djcelery.backends.database.DatabaseBackend object at 0x1026842d0>