Ask Your Question

Revision history [back]

click to hide/show revision 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:

  1. Import the model that contains the object you want to retrieve:
from your_app.models import YourModel
  1. Define your celery task and pass the primary key of the object as an argument:
@task
def my_task(pk):
  1. Retrieve the object using the primary key and extract the integer value:
obj = YourModel.objects.get(pk=pk)
value = obj.int_field_name
  1. Use the integer value as required:
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.