I have two Pythonapplications 'frontend' and 'fv'. in my fv app is my tasks.py file and in my frontend app is my views.py file to render my views.
Now I have a view where I can choose some parameters get these with request.POST. and now I'd like to call a a task method FunctionRDynamic and pass the parameters from my view form.
Method in views.py:
if request.method == 'POST':
form1 = dataproviderInstrumentForm(request.POST)
form2 = dynamicTimeseriesForm(request.POST)
if form1.is_valid() or form2.is_valid():
filters = form2.cleaned_data['filter']
estimator = form2.cleaned_data['estimator']
windowSize = form2.cleaned_data['windowSize']
FunctionRDynamic.delay(estimator, windowSize, timeseries)
FunctionRDynamic is my method in the tasks.py file in the oder application, but this method will not execute.
For my tasks I use celery. All is written in Python and I use Django as mvc framework.
Does anyone have suggestions?
From what I have understood here's the solution. While defining celery tasks do this:
@celery.task
def file_transfer(password, source12, destination):
# Do stuffs with paramters
Now in your views.py
do this:
def test(View):
# Get the data from post
if request.method == 'POST':
name = request.POST['name']
# And get all the variable you need for the tasks
# Now call the task like this
file_transfer.delay(name, 'test', 'test')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With