1 | initial version |
Assuming that you want to retrieve an integer value by passing the primary key of an object in Django, you can achieve this by following these steps:
from your_app.models import YourModel
@task
def my_task(pk):
obj = YourModel.objects.get(pk=pk)
value = obj.int_field_name
print(value)
return value
You can call this celery task passing the primary key of your object as an argument and you will retrieve the integer value at the end of the task.