Django Channels Tutorial || Real-time Tables using WebSockets in Django | 2020

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 81

  • @skysavani7095
    @skysavani7095 3 роки тому

    Thanks for Amazing Tutorial. I've seen both videos and code also working......

  • @aashayamballi
    @aashayamballi 4 роки тому +2

    This is really great stuff, Thank you!
    For WebSocket updates instead of sending the updates from the python code from the jupyter notebook, if you had used Django itself, that would have been more practical from Django point of view. Please make a tutorial on Django view updates that will trigger channels to send the data.
    Again thank you so much for all your efforts. Learning a lot from you :)

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      The idea of using notebook is to represent the behaviour of any edge device which is generating data and sending it to the server and the user is getting updates in the ui.

    • @aashayamballi
      @aashayamballi 4 роки тому +1

      @@technologyfornoobs
      In this case, if an edge device is generating data then saving the data in DB and all will be done in consumer's receive method? if yes then ORM and all are synchronous how would we do that? using sync_to_async?
      Also a suggestion, instead of data generated from another source, Django view itself does the thing (for example, if the user had put some large file for processing and showing the progress of it in the progress bar, a real-time notification, etc) will be more practical in terms of Django.

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      1st, yes receive method is the place to save or manipulate data, and as we have already inherited AsyncWebsocketConsumer in our class we do not need sync_to_async, just async and perform usual actions.
      I am not much familiar with other frameworks async functionality, but in regular views, you still need to give a response at the end, and if the task is not completed like file upload, how it will reach to consumer.py I am not sure.
      I have read people using celery for the same task, need to explore more though.

    • @aashayamballi
      @aashayamballi 4 роки тому

      @@technologyfornoobs Okay thank you 😊

  • @ruylopez26
    @ruylopez26 3 роки тому

    23:30, the subscriber is not able to connect, async def queue_factory() -> asyncio.Queue[str]:
    TypeError: 'type' object is not subscriptable

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому

      not sure about this error, you are in same env as in the video or diff python version

    • @ruylopez26
      @ruylopez26 3 роки тому

      @@technologyfornoobs I couldn't find a way to get your environment "py36", could you please share it?

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому

      Get the req.txt file from github.com/sharmasw/realTime-Tables-with-Django-Channels
      create env
      install it in "pip install -r req.txt"
      activate env

    • @ruylopez26
      @ruylopez26 3 роки тому

      @@technologyfornoobs Thank you so much!!

  • @BaljeetKaur-ky6wk
    @BaljeetKaur-ky6wk 3 роки тому

    Great tutorial bro.thanks for awesome contents

  • @alitatl9780
    @alitatl9780 4 роки тому +1

    its gonna be legen wait for it ...

  • @Salmankhancodes
    @Salmankhancodes 4 роки тому +1

    Great tutorial Sir ♥️

  • @GabrielRibeiro-xr3bx
    @GabrielRibeiro-xr3bx 4 роки тому +1

    Hello there.
    So I used everything I learned to make an APP of my own design here and wanted to deploy it to heroku, but i can't make it work. First because at deploying I encounter many errors, one of them is that twisted is not supported in heroku and is necessary for channels to run. Would you prepare a tutorial about deploying a real-time project like the one in the video?
    Or could you point me out if I would have to use Heroku Redis and maybe other kind of code for deployment.
    Thank you very much sir

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      I have not actually done it before, real time app deployment, but I assume you would have already followed the link blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django

    • @GabrielRibeiro-xr3bx
      @GabrielRibeiro-xr3bx 4 роки тому

      @@technologyfornoobs Yes I did. Unfortunately got stuck on the handshake when openning the WSS. Trying to figure it out :0

  • @bram-midage
    @bram-midage 4 роки тому +1

    well done sir, can we use channels to detect change in database? if so, please make the tutorial, thank you.

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      detecting change in DB you need to write logic in DB itself, using triggers. my guess for the solution.

  • @philmorgan6276
    @philmorgan6276 3 роки тому

    The Websocket disconnects automatically after around 30-40 seconds, I'm sending the data through a scraper which takes about a minute to send. Where can I configure the timeout settings in django channels?

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому

      are you not subscribing to the socket before sending it, even if it is for long duration, you can re subscribe as your websocket url will be same right?

  • @prathyushavaigandla6032
    @prathyushavaigandla6032 4 роки тому

    hii ,do you have any tutorial of making charts dynamic in django???

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Not yet, but I have done it in past, it's lot of if else, and mostly on javascript

  • @ruylopez26
    @ruylopez26 3 роки тому

    Very helpful content, but I need to display real time data on my website, the scraping python program is ready, could you please help me by explaining how should I link these programs or is there a different method altogether for this?

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому +1

      scrapping could be a separate program as it has to continuously run and keep updating the data. then you can use websockets to send the data to your app.

    • @ruylopez26
      @ruylopez26 3 роки тому

      @@technologyfornoobs Okay, thank you so much!

  • @Speaks4itself
    @Speaks4itself 4 роки тому

    Can you get the data instead from your models and use celery to continuously run a task?

  • @GabrielRibeiro-xr3bx
    @GabrielRibeiro-xr3bx 4 роки тому +1

    Hi there,
    Tahnk you for the tutorial, really really helpful. I am currently having an issue in the websocket part inside the jupyter notebook. When i try to run the second line i get the error message:
    ---------------------------------------------------------------------------
    TypeError Traceback (most recent call last)
    in
    1 import websocket,json,random
    ----> 2 ws = websocket.WebSocket()
    TypeError: __init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile'
    I tried to search google for an answer, but haven`t found one. In websocket documentation they say it should run normally. Any idea on how to solve this? Thanks again.

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +2

      please install websocket-client and try again

    • @GabrielRibeiro-xr3bx
      @GabrielRibeiro-xr3bx 4 роки тому

      ​@@technologyfornoobs Yes, that was the problem. I had only installed websocket.
      I am now facing another problem which is "aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'".
      Might be some problem in windows not supporting redis oficially. Should I try and install another version of redis?
      Thanks

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Hi could you please download the zip file from the github and try the redis, that would solve your problem

    • @GabrielRibeiro-xr3bx
      @GabrielRibeiro-xr3bx 4 роки тому

      @@technologyfornoobs Hello sir,
      I did it through the link shown in video (github/servicestack/redis-windows) and executed the redis-server.exe file. It still gives me the error. "aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'".
      HTTP GET / 200 [0.31, 127.0.0.1:59219]
      Not Found: /favicon.ico
      HTTP GET /favicon.ico 404 [0.32, 127.0.0.1:59219]
      WebSocket HANDSHAKING /ws/tableData [127.0.0.1:59579]
      WebSocket CONNECT /ws/tableData [127.0.0.1:59579]
      Exception inside application: ERR unknown command 'BZPOPMIN'
      Traceback (most recent call last):
      File "C:\DEV
      ealtime\lib\site-packages\channels\sessions.py", line 183, in __call__
      return await self.inner(receive, self.send)
      File "C:\DEV
      ealtime\lib\site-packages\channels\middleware.py", line 41, in coroutine_call
      await inner_instance(receive, send)
      File "C:\DEV
      ealtime\lib\site-packages\channels\consumer.py", line 58, in __call__
      await await_many_dispatch(
      File "C:\DEV
      ealtime\lib\site-packages\channels\utils.py", line 58, in await_many_dispatch
      await task
      File "C:\DEV
      ealtime\lib\site-packages\channels\utils.py", line 50, in await_many_dispatch
      result = task.result()
      File "C:\DEV
      ealtime\lib\site-packages\channels_redis\core.py", line 452, in receive
      message_channel, message = await self.receive_single(
      File "C:\DEV
      ealtime\lib\site-packages\channels_redis\core.py", line 507, in receive_single
      content = await self._brpop_with_clean(
      File "C:\DEV
      ealtime\lib\site-packages\channels_redis\core.py", line 345, in _brpop_with_clean
      result = await connection.bzpopmin(channel, timeout=timeout)
      aioredis.errors.ReplyError: ERR unknown command 'BZPOPMIN'
      WebSocket DISCONNECT /ws/tableData [127.0.0.1:59579]
      Could not find help about this on stackoverflow and google. Do you have any ideia what that is?

    • @GabrielRibeiro-xr3bx
      @GabrielRibeiro-xr3bx 4 роки тому

      Ok, there is another github which contains another version of redis: github.com/tporadowski/redis/releases
      For anyone having the same issue. That might be helpful. It is working fine

  • @ronitjain6704
    @ronitjain6704 4 роки тому

    thank you very much !! helped me a lot

  • @harshitsantosh825
    @harshitsantosh825 4 роки тому

    Great video. One doubt. Can django channels be used for video streaming between browsers using webrtc?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      to my knowledge which is limited, people use some other tools in conjunction with Django, mostly with the help of Nginx. like hosting files logic. Not sure about the library webrtc in this context

    • @harshitsantosh825
      @harshitsantosh825 4 роки тому

      @@technologyfornoobs ok thanks

    • @harshitsantosh825
      @harshitsantosh825 4 роки тому

      @@technologyfornoobs Can we make a video calling app with django channels?

    • @123sid789
      @123sid789 4 роки тому

      @@harshitsantosh825 absolutely

  • @123sid789
    @123sid789 4 роки тому

    when we are using async, how can we update the database?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      at receive part of the consumer.py.

    • @123sid789
      @123sid789 4 роки тому +1

      @@technologyfornoobs it would be great if you could show an example in future tutorial.

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому +1

      will update!

  • @beshrumgaming1295
    @beshrumgaming1295 3 роки тому

    Iam receiving data from api in views and prints to terminal works fine. I just want to send data from views to template real time

    • @technologyfornoobs
      @technologyfornoobs  3 роки тому

      you need to re-evaluate it, if you are making rest calls, then you need to push the data to the server and all the websockets still holds true, the rest call has to be served in a scheduled manner or somewhere outside of your app

  • @marvinlopez1539
    @marvinlopez1539 4 роки тому

    Amazing Tutorial. I followed both. And I was able to run them!
    I have a question, It is possible to run the two "channels" in parallel?
    I mean: Have the table refreshing and having the graph (showed in the previous tutorial) working in the same page, how can I achieve that?

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Yes, absolutely,you need to pass the channel name dynamically,like we do it in URL patterns.

  • @AliHasanov
    @AliHasanov 4 роки тому +1

    I guess your virtualenv isn't working right. If you look at the req.txt file then you will know :/

    • @lets_see_777
      @lets_see_777 4 роки тому

      yeah he is probably not using virtual env

  • @django3861
    @django3861 3 роки тому

    thx
    so much

  • @akhillshetty2140
    @akhillshetty2140 4 роки тому

    Can you set up video calling/chat using Django Channels and WebRTC? Please do a video about that, I'm sure everyone would want to know how to do that

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      yes sure, but doing it through python/Django won't be good for production purpose as its not matured yet.

    • @quocbao6046
      @quocbao6046 4 роки тому

      @@technologyfornoobs I want to see how video calling/chat works in Django too. Please do that video ! Thanks for the amazing tutorial

  • @dantedt3931
    @dantedt3931 4 роки тому

    Best.Thank you

  • @dheeraj5023
    @dheeraj5023 4 роки тому

    Please sir, can you make video on django + channels + socket in Hindi

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      ua-cam.com/video/32iJlPDNLQY/v-deo.html
      This one has what you want!

  • @ahmeddoudou2262
    @ahmeddoudou2262 2 роки тому +1

    python -m pip install -U channels["daphne"]

  • @rangabharath4253
    @rangabharath4253 4 роки тому

    awesome

  • @nomanislam3157
    @nomanislam3157 4 роки тому

    Sir please create an real state ml react dj web ...

  • @HarshvardhanV
    @HarshvardhanV 4 роки тому

    Thanks man , awesome stuff . I have been following you and implemented some of ur code / training in my app. I am stuck in one of the operation that am doing in Django . Need your help ,would be great if you can give me your email id i can share my app video and the exact problem .

    • @HarshvardhanV
      @HarshvardhanV 4 роки тому

      Also , keen to know if you would love to work on consultancy basis / project basis with us . Thanks!

    • @technologyfornoobs
      @technologyfornoobs  4 роки тому

      Techfornoobs01@gmail.com

    • @HarshvardhanV
      @HarshvardhanV 4 роки тому

      @@technologyfornoobs I have emailed you , please check .