I have a celery task that runs periodically and fetches some data for all companies that use a certain accounting service. I now need to make that task run on-demand with a click of a button, and fetch only the current company's data.
Modified celery task:
@APP.task
def import_data_for_company(company_id):
for integration in settings.INTEGRATIONS:
if integration["owner"]["company_id"] == company_id:
print("omlette du fromage")
Current button in Django template
{% for integration in settings.INTEGRATIONS %}
{% if company.company_id == integration.owner.company_id %}
<div class="button">
<a class="btn" href="#">Import Data</a>
</div>
{% endif %}
{% endfor %}
I need to trigger that task from the Django template and pass a company ID as an argument while doing it. But according to this comment, I cannot pass arguments from the Django template. Writing a custom template tag/filter seems not to help here.
What are my options for calling that function via this button?
Have to note, that I'm very green at this still.