On 25/06/13 12:35, lx wrote: > hi all: > I want to do someing after "return HttpResponse(html)". > for example > """""""""""""" > from django.http import HttpResponse > import datetime > def current_datetime(request): > now = datetime.datetime.now() > html = "<html><body>It is now %s.</body></html>" % now > return HttpResponse(html) > """"""""""""""""""""""""""""" > > Actually, I have a question that I need first give a response to the > client, second I do something else. > How to solve this? > > Thank you > > You can't do anything after your view (= python function) returns. If you need to perform a task but don't want to keep the user waiting, you should look into Celery. This is a Distributed Task Queue: you can start a task that a worker will execute in the backend. Your view can return immediately, being very responsive to the user. In the meanwhile the worker will perform the extra work in the background.
-- Kind regards Michael Anckaert
signature.asc
Description: OpenPGP digital signature

