Introduction to async views in Django | async/await in Django views

  Рет қаралды 39,024

Pyplane

Pyplane

Күн бұрын

Пікірлер: 94
@SharukhKhan-cq5zd
@SharukhKhan-cq5zd 2 жыл бұрын
After Reading Documentation. I was confused. you did it very well. thanks from India...
@professionalfacepuncher8361
@professionalfacepuncher8361 4 жыл бұрын
at last !! someone did an example video, I've been waiting so long for this (I've read the docs, but i wanted to know if i am doing things wrong, always better to watch an expert do things to get a perspective than just wing it) thanks alot man , subbed and liked.
@Pyplane
@Pyplane 4 жыл бұрын
Thank you :) however if you want to see a real Django expert in action - check out Daniel Feldroy’s channel. I’m not an expert just a practicioner :)
@aashayamballi
@aashayamballi 4 жыл бұрын
True! Luke is ahead of everybody😀
@professionalfacepuncher8361
@professionalfacepuncher8361 4 жыл бұрын
@@Pyplane thanks for your humble recommendation will check it out
@professionalfacepuncher8361
@professionalfacepuncher8361 4 жыл бұрын
DEP009 is some exciting stuff, async enabled querysets will be coming soon i'm just wondering what this will mean for the rest framework.
@aashayamballi
@aashayamballi 4 жыл бұрын
Just had a question, can't we use async views in Django rest framework? Because serialization and other things happen there right?
@milonmahato19
@milonmahato19 4 жыл бұрын
Finally, I found it. 😍😍. Please keep going. Take love.
@Pyplane
@Pyplane 4 жыл бұрын
Hi Milon. Happy you're still here and very glad you liked the video. Cheers! :)
@sansinghsanjay
@sansinghsanjay 2 жыл бұрын
Very nice, well-organized, and informative video. I got huge help by watching your other videos on Django. Thanks a lot for this wonderful work and please keep it up!
@MrValVet
@MrValVet 2 жыл бұрын
Your tutorials are so good, I'm going to go through all of them :)
@rramos550
@rramos550 2 жыл бұрын
Great explanation. Just add the "total" to the httpresponse instead of counting the seconds or searching the log. thumbs Up!
@jameskulu
@jameskulu 4 жыл бұрын
Was waiting for this. Great one
@Pyplane
@Pyplane 4 жыл бұрын
Hi James. Thanks. Happy you liked it :)
@paborlouise319
@paborlouise319 4 жыл бұрын
Finally async views. Great one 🔥
@Pyplane
@Pyplane 4 жыл бұрын
Thank you Pabor! :)
@aashayamballi
@aashayamballi 4 жыл бұрын
Hey Luke! This channel really deserve more and my suggestion would be give a tutorial on Brad Traversy's channel. People will definitely follow you here. Django 3.1 async views I was waiting for this tutorial and here we go... You never disappoint us. Keep up the good work Luke an never stop producing such a good tutorials. Many many thank you 🙏😊
@Pyplane
@Pyplane 4 жыл бұрын
Thank you Aashay. Regarding the views on my channel - I know they aren’t spectacular, but I’m very happy :) I honestly didn’t believe I’ll get 1000 subscribers. As it is for Brad Travesy channel I have to first improve my english :) thanks a milion times for the support!
@aashayamballi
@aashayamballi 4 жыл бұрын
@@Pyplane you're awesome!
@Shaunmcdonogh-shaunsurfing
@Shaunmcdonogh-shaunsurfing 4 жыл бұрын
Great tutorial and thank you
@nareshkumar-mm3hq
@nareshkumar-mm3hq 4 жыл бұрын
Many thanks Luke for @nother great video
@Pyplane
@Pyplane 4 жыл бұрын
Thanks for watching Naresh! :)
4 жыл бұрын
You should use `ab` to confirm that the async view would enable more requests to be handled as a effect of not blocking requests to execute while they wait for the io.
@MartinoxxHD
@MartinoxxHD 2 жыл бұрын
what does ab mean?
@gregcompton9631
@gregcompton9631 Жыл бұрын
For Django 4.x - You need to change @sync_to_async to @sync_to_async(thread_sensitive=False) before get_stories_async() and get_movies_async() functions. Huge thanks to @ssadxuyui5060 who first commented the solution over a year ago in a reply.
@BadCountryRanch
@BadCountryRanch Жыл бұрын
that was it! thank u!
@ukaszkozicki7721
@ukaszkozicki7721 Жыл бұрын
Thanks a lot man, I was really beginning to think I'm on the wrong side of a bad dream :)
@NotBeHaris
@NotBeHaris 4 жыл бұрын
another great tutorial Respect.
@Pyplane
@Pyplane 4 жыл бұрын
Thank you Muhammad :)
@bentwite3093
@bentwite3093 4 жыл бұрын
This is a most watch :)
@rangabharath4253
@rangabharath4253 4 жыл бұрын
awesome as always. tq so much :-)
@Pyplane
@Pyplane 4 жыл бұрын
thanks for watching :)
@zorojuro5106
@zorojuro5106 4 жыл бұрын
thanks a lot mate keep the good work :)
@Pyplane
@Pyplane 4 жыл бұрын
Thanks for watching :) cheers!
@vaibhavgupta4413
@vaibhavgupta4413 4 жыл бұрын
@Pyplane awesome 😈😈😈😈😈
@rajughorai3909
@rajughorai3909 4 жыл бұрын
Thanks for this video.
@Pyplane
@Pyplane 4 жыл бұрын
Thanks for watching :)
@JustPython
@JustPython Жыл бұрын
Nice job
@seandenny6430
@seandenny6430 4 жыл бұрын
Amazing!!!
@Pyplane
@Pyplane 4 жыл бұрын
Thank you! 🙂
@yukselbastan4687
@yukselbastan4687 4 жыл бұрын
great video thank you Lukas.
@Pyplane
@Pyplane 4 жыл бұрын
Hi Yuksel :) glad you liked it :))
@yukselbastan4687
@yukselbastan4687 4 жыл бұрын
@@Pyplane improvements are always good, thank you. And by the way i made it trough by atthost, finally it worked .
@Pyplane
@Pyplane 4 жыл бұрын
@@yukselbastan4687 Wowowow...congrats. That's a huge thing - make it work without knowing the Polish language. Congrats 100x !
@yukselbastan4687
@yukselbastan4687 4 жыл бұрын
@@Pyplane thank you very much, you as our teacher you should become the thanks ;), just one question please, can i work years with atthost without any problems i mean should i make a 5 year payment ?
@Pyplane
@Pyplane 4 жыл бұрын
@@yukselbastan4687 I don't know that :/ I pay annually each time
@AbhishekBharadwaj-s1i
@AbhishekBharadwaj-s1i Жыл бұрын
When I define the post function in view as "async" like the async def main_view_async(), I keep getting this error: AssertionError: Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `` What's the way around this?
@siya.abc123
@siya.abc123 4 жыл бұрын
Dope video!
@Pyplane
@Pyplane 4 жыл бұрын
Thank you!:)
@Isaacv-mk3mi
@Isaacv-mk3mi 4 жыл бұрын
can we use this with django rest projects?
@DimitrisKougioumtzis
@DimitrisKougioumtzis 2 жыл бұрын
very good tutorial , can i use async with class based views ? does django supports it ?
@stevemapes9672
@stevemapes9672 2 жыл бұрын
In as of Django 3.1 - docs.djangoproject.com/en/4.1/topics/async/#async-views
@pinchasnachmani1418
@pinchasnachmani1418 3 жыл бұрын
Thank you, What if i did not use with the await command, is it impossible (line 56)?
@АнатолийБугаков-е9г
@АнатолийБугаков-е9г 3 жыл бұрын
Isn't Movie.objects.all() a sync function and hence blocks the requests?
@djangodeveloper07
@djangodeveloper07 3 жыл бұрын
hi great tutorial as usual. i was finding something else and found you again. for example if we have 1000 requests data to show in template. can we show data of each request whenever request data returns like request 1: loading request 2: success here is your data value request 3: success here is your data value request4: loading request5: fail etc and each request is on different api . feel like real app data. need it very badly any guide or help ?
@jayachandraB
@jayachandraB 3 жыл бұрын
how to capture the return values from async get movie and async get stories in main view async
@amanguptadev
@amanguptadev 4 жыл бұрын
Bro i am uploading images on GCP and then create entry in database but when i run it. It is only create entry not upload image
@danielaceros5723
@danielaceros5723 4 жыл бұрын
Thanks Luke!
@Pyplane
@Pyplane 4 жыл бұрын
Hi Daniel! Nice to hear from you again :) happy you liked the video :) Cheers!
@danielaceros5723
@danielaceros5723 4 жыл бұрын
@@Pyplane ohh my friend. That's great you remember me! I've learnt a lot from you. Keep going!. Dziękuję Ci!
@Pyplane
@Pyplane 4 жыл бұрын
@@danielaceros5723 Of course I do. My memory isn't perfect but I'll always remember the people who motivated me to carry on :) I am very happy and proud that you learned something from me :) Have a great day :) btw. nice Polish :))
@yukselbastan4687
@yukselbastan4687 4 жыл бұрын
1.77K Subscribers nice :D
@dgiri2333
@dgiri2333 Жыл бұрын
How to get async function orm result send back to temple
@NotBeHaris
@NotBeHaris 4 жыл бұрын
I have a question that how we get data from database without refreshing page. Else ajax because i read in one video comment that it is not good way.
@Pyplane
@Pyplane 4 жыл бұрын
I personaly don't work with ajax - the reason is that the code can get messy when building more advanced applications. For me a much better and easier way to do this is using django rest framework and react on the frontend. A tutorial on this will appear on the channel pretty soon. Cheers
@NotBeHaris
@NotBeHaris 4 жыл бұрын
@@Pyplane i am waiting for this and django channel
@NotBeHaris
@NotBeHaris 4 жыл бұрын
how much i wait for this..?
@Pyplane
@Pyplane 4 жыл бұрын
@@NotBeHaris the seconda part of the crypto app will be released at the beginning of September :)
@stevemapes9672
@stevemapes9672 2 жыл бұрын
AJAX or Websockets are the most common approach. The latter will be faster due to less network overhead
@ckom9
@ckom9 3 жыл бұрын
Thanks!
@wilmerferneycubidesporras7774
@wilmerferneycubidesporras7774 3 жыл бұрын
how to apply this concept to a real world example?
@dexterslab7750
@dexterslab7750 4 жыл бұрын
I just ran your code and I am seeing same result.. am i missing something..
@ИльяЯгупов-н4я
@ИльяЯгупов-н4я 3 жыл бұрын
For me also the sync and async requests have the same execution time. I used the code from git.
@rodolfo4880-e4j
@rodolfo4880-e4j 3 жыл бұрын
me too, what's going on?
@rodolfo4880-e4j
@rodolfo4880-e4j 3 жыл бұрын
It works in django 3.1 but not django 3.2
@MrNiceseb
@MrNiceseb 3 жыл бұрын
Also the same 7 secs regardless in Django 3.2
@DeepakKumar-uz4xy
@DeepakKumar-uz4xy 3 жыл бұрын
@@rodolfo4880-e4j i am also using 3.1.2 verison but result is same.
@deepanshuaggarwal7042
@deepanshuaggarwal7042 4 жыл бұрын
Hi, I like this method. But, i have 1 doubt. It it necessary to wait for task to complete as my task will take around 30 minutes to complete.
@Pyplane
@Pyplane 4 жыл бұрын
Hi. I don’t know the details of your task but maybe consider running it in the background? Cheers
@ravikumarighare5297
@ravikumarighare5297 4 жыл бұрын
@@Pyplane hi, i want hep regarding this. my view takes more than 6 seconds but timeout happens in 5 secinds. how do i send http response first and then do processing. in this example it waits in both cases. i dont want to wait. return response first and then do things. it is possible using async
@coolrezaul
@coolrezaul 3 жыл бұрын
@@ravikumarighare5297 use threading
@ravikumarighare5297
@ravikumarighare5297 3 жыл бұрын
@@coolrezaul thanks. threading worked
@DeepakKumar-uz4xy
@DeepakKumar-uz4xy 3 жыл бұрын
i tried this but this is not working. sync to async function also running synchronously
@berkayertem5938
@berkayertem5938 3 жыл бұрын
Try Django version 3.1
@amaangigani9372
@amaangigani9372 2 жыл бұрын
Not working. Please update or remove this video
@Pterry23real
@Pterry23real 3 жыл бұрын
Not really a good video. You doesn't explain very much, your toy example is too trivial to show something and also it just doesn't work as aspected. And yeah I saw the edited note about asyncio.sleep but if you can edit this you should have rather re-record this video. Cool that you make videos to show off new stuff but please more effort the net is full of broken toy examples like this. Personally I don't want that python becomes the next js in this regard.
ASYNCIO НА ПРАКТИЧЕСКОМ ПРИМЕРЕ
22:44
luchanos
Рет қаралды 28 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Asyncio in Python - Full Tutorial
24:59
Tech With Tim
Рет қаралды 112 М.
Django async HTTP requests with asyncio and aiohttp
20:32
Very Academy
Рет қаралды 23 М.
Django Channels & WebSockets Oversimplified
16:35
Dennis Ivy
Рет қаралды 147 М.
#16. Основы ORM Django за час | Django уроки
1:03:59
AsyncIO, await, and async - Concurrency in Python
9:12
Socratica
Рет қаралды 117 М.
Создание rest api на Django Ninja | django async | #1 | Михаил Омельченко
1:14:18
Михаил Омельченко | Django School
Рет қаралды 6 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН