Open jacobwegner opened 11 years ago
Hi Jacob,
Yup. The documentation on jquery-celery is pretty abysmal right now :(
Here's a todo-django project using Jobtastic and jquery-celery that did for a presentation. Hopefully it will help at least a little bit. site_base.html is where the djcelery
magic gets hooked in.
It's a pretty good example, since it uses progress and has error/success callbacks, but it's a bit more complex than the simplest example possible.
Would you be willing to take some quick notes on the things that tripped you up starting from that example? Maybe then I could adapt the code there as jquery-celery documentation and then specifically address the things that were confusing/surprising to you.
I'm sorry that I don't have better documentation here already. If you have questions, definitely ask them here and I'll try and respond quickly (at least for the next couple of hours, since I'm already writing documentation for other things anyway).
Thanks for asking the question! -Wes
Thanks; looking at todo-django was enough to get me started.
The error/success callbacks are a big part of why I'm excited to work what you're doing with jobtastic and jquery-celery into some of my projects. I'll come back to this issue later in the week to try and capture my thoughts and do whatever I can to help improve documentation...out of time for today.
Thanks for the great work to date on both of these projects.
I know this is old, but I'd also like to see a sample HTML file. The AJAX part of this whole stack is my weakest point, and that's the one that's not in the docs. =)
@bkeifer I'll see if I can add something soon.
@bkeifer: I'd love if you took a look at the updated README on this branch with the sample file included.
Ask me follow-up questions here if you're still stuck, and we can iterate on the file/instructions until you're up and running.
Hopefully that way we can end up with a good PR to the README that assumes nothing but gets other new users to the project up and running/
Progress! I'm slowly working through this and getting close.
First thing I found is an extra semicolon on the closing } for on_other (line 39).
The task is started and completes successfully (verified via flower), but I'm getting the "Something went horribly wrong" message on the web page.
My console shows the following URL throwing a 404: http://localhost:8080/task/f231d5df-fbc6-45b6-acf1-625f4a669134/status/?_=1462994476693
This makes sense, since I don't have anything at /task/ (that I know of, at least...). Where is that URL handled? Is that a part of the Celery setup I missed? If it matters, this is in a Django app.
EDIT: I'm getting there. I think I've almost gotten my view for /task/ working. I'll be happy to provide a copy for the readme once it's working.
So here's what I've got for my /task view. It's not pretty, but it works. Does this jive with what you'd expect to see from the method handling that call?
def task(request, task_id):
data = 'Fail'
task = AsyncResult(task_id)
# Task is still in progress
if type(task.result) is dict:
data = {'task': {'result': {}}}
data['task']['id'] = task_id
data['task']['status'] = task.state
data['task']['result']['progress_percent'] = task.result['progress_percent']
# Task has finished.
elif type(task.result) is list:
data = {'task': {}}
data['task'] = {
'status': task.state,
'id': task_id,
'progress_percent' : 100,
}
return HttpResponse(json.dumps(data), content_type='application/json')
@bkeifer: You're on the right track.
Celery includes a task status view that you can wire up in the urls.py
for your project. It corresponds to the path defined in jquery-celery:
from djcelery.views import task_status
urlpatterns = [
url(r'^admin/', admin.site.urls),
...
url(r'^task/(?P<task_id>[\w\d\-\.]+)/status/', task_status),
]
That was the missing piece. Thank you!
I'm not very familiar with jQuery plugins, and I'm trying to use jquery-celery with jobtastic for the first time.
It'd be great if README.md had an example template that could help folks like me to get started.
I'd be happy to do a PR for this, but I don't know how to create that example template ;-)
I'm guessing something like: