私は最初にdjangoビューで応答を返したいと思っています。最初に応答を返す方法はありますが、応答後も何か他のことをしますか? django
は、最初の応答を返すチャンスがあるかどう
class Res(View):
def post(self, request):
data = request.POST
new_obj = Model.objects.create(name=data.['name'])
# what is below does not have to be done RIGHT AWAY, can be done after a response is made
another_obj = Another()
another_obj.name = new_obj.name
another_obj.field = new_obj.field
another_obj.save()
# some other looping and a few other new models to save
return JsonResponse({'status': True})
は、だから私は疑問に思って.....さんは、私が一例として、このようなものを持っているとしましょうか?上記のことは、私が意味するものの例です。
私は、可能ならば、これは、ジャンゴで行うことができるかどうかわからない、誰かが私は、これは事前に
感謝を行うことができる人を知らせることができます。
このためにセロリのタスクを使用できます。 – neverwalkaloner
はい、セロリはそれを行う優れた方法の1つです。ここでそれについて読む:https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/ –
thx thx、私はすぐにこれを試し、それがどのように動作するか見る。 – Dora