Debugging a Dockerized Django app with VSCode

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024

ความคิดเห็น • 44

  • @sofianeamr7398
    @sofianeamr7398 2 หลายเดือนก่อน +1

    Helped so much on doing the same with odoo tnx

  • @charliesta.abc123
    @charliesta.abc123 3 ปีที่แล้ว +1

    Doesn't work for me, the debug console turns orange for like a second and stops. I wonder because I've followed all the steps

  • @rodionbykov
    @rodionbykov 2 หลายเดือนก่อน

    Not seem to use docker-compose debug though, but mentioning it makes confusion.

  • @fitnessislive1964
    @fitnessislive1964 2 หลายเดือนก่อน +1

    i got this error when i debugging. a debug stop at line "execute_from_command_line(sys.argv)" in the manage.py. the error message is "Exception has occurred: OperationalError
    could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
    psycopg2.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
    The above exception was the direct cause of the following exception:
    File "d:\django projects
    ecipe-app-api\app\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
    File "d:\django projects
    ecipe-app-api\app\manage.py", line 22, in
    main()
    django.db.utils.OperationalError: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?"

  • @vostbur1
    @vostbur1 3 ปีที่แล้ว +2

    How can I resolve the problem "Import "django.http" could not be resolved from source Pylance(reportMissingModuleSource)"? VSCode does not allow the import of the django library added to the docker container.

  • @antoniomourao2537
    @antoniomourao2537 2 ปีที่แล้ว +1

    I have issue when run debug: timed out waiting for launcher to connect

  • @SadashivaNarayana
    @SadashivaNarayana 3 ปีที่แล้ว +1

    I am getting the error "Debug Adapter Executable not provided" error after executing docker command. App doesn't execute in debug mode. Please help.

  • @markera1000
    @markera1000 3 ปีที่แล้ว +2

    I have a problem:
    1. Added a service "db" in docker-compose.yml with postgres image.
    2. When referencing the "db" in django's settings.py, the vscode debug shows error, where it says there is no "db" host.
    Do you know what it can be?

    • @LondonAppDeveloper
      @LondonAppDeveloper  3 ปีที่แล้ว

      Probably a typo or indentation issue in docker-compose.yml.... Also, check you didn't add spaces around environment variables in docker-compose.yml.

    • @gabrielhenrique2430
      @gabrielhenrique2430 2 ปีที่แล้ว

      Did you solve it? I'm here with same problem.

    • @markera1000
      @markera1000 2 ปีที่แล้ว

      @@gabrielhenrique2430 I'm not using this vscode integration anymore. Terminal only.

  • @AllPsychBouldering
    @AllPsychBouldering 3 หลายเดือนก่อน

    This seems to fail when I'm already using postgres for my project, is there any way to fix this error:
    django.db.utils.OperationalError: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
    When I check docker ps my database is in fact running on 5432 and healthy. Thanks!

  • @silkogelman
    @silkogelman 2 ปีที่แล้ว

    Great video, thank you!
    I'm using PyCharm myself, but I picked up a couple of interesting Docker nuggets from this like the user part.

  • @eduardolucas391
    @eduardolucas391 ปีที่แล้ว

    Awesome! Exactly what I was looking for...

  • @alexblack4684
    @alexblack4684 3 ปีที่แล้ว +1

    Thanks for the video
    I need to learn docker

  • @tree2rhym
    @tree2rhym 2 ปีที่แล้ว

    did not understand , when you click on run and stat debugging how visual studio knows where to connect ?
    how it knows that I have to connect to container end point instead of starting it locally?

  • @yates6789
    @yates6789 ปีที่แล้ว

    When I tried applying this to my project I got an error in VSCode 'Invalid message: "pythonPath" is not valid if "python" is specified'.
    I decided to instead clone your repository to try and play about with debugging with your exact code. However, I get the same error message there too?
    Any help would be great!

  • @RodrigoEstevaoRodrigues
    @RodrigoEstevaoRodrigues 3 หลายเดือนก่อน

    Thank you, it was very useful!

  • @mimocrocodile5069
    @mimocrocodile5069 ปีที่แล้ว

    Great tutorial
    I am so glad to discover this channel

  • @BruceCichowlas
    @BruceCichowlas 2 ปีที่แล้ว

    This is a great tutorial and the blog version is great, too. This is about the 5th of similar tutorials that i've tried. Perhaps most of them ran correctly at some time, but I couldn't follow them through to completion now. Of course, I might have misunderstood something or done something wrong, too.
    But what I was really looking for was a tutorial like this using PyCharm and targeting Virtual Box. I couldn't get any of those to work for me, but I am hoping what I learned here will transfer. I can't do much about the Virtual Box requirement, but I am okay with using Code if that is the easier path.

  • @tarolee7323
    @tarolee7323 2 ปีที่แล้ว +1

    Perfect!!!!

  • @user-xv1iq3km2w
    @user-xv1iq3km2w 3 ปีที่แล้ว

    Hello, can you tell me if it is possible to work on vs code using Django modules auto-import? I assume that by entering, for example, LoginView and pressing Ctrl+Space, a suggestion will appear to import this class from internal Django modules, if, for example, I do not know where exactly in which module it is located. Please help me..

  • @DidCoding
    @DidCoding 2 ปีที่แล้ว

    Perfect tutorial mate!! Keep it up

  • @jonnywillone
    @jonnywillone 2 ปีที่แล้ว

    Great video!!

  • @jarorkwong8042
    @jarorkwong8042 3 ปีที่แล้ว

    It takes me 30 seconds to enter the debugging mode inside the contain, is there a way to speedup the startup? Thanks

    • @jarorkwong8042
      @jarorkwong8042 2 ปีที่แล้ว

      @@Neeoooo You can connect to a docker container on VSCode with SSH. Then you debug the Django app inside the container.

  • @asian1nvasion
    @asian1nvasion 2 ปีที่แล้ว

    Thanks for another great tutorial. I think it's worth adding this to the existing Udemy course as 'Bonus' content (I got the advanced course).
    Does anyone know why VScode throws an error saying:
    "Invalid message: either "program", "module", or "code" must be specified"???
    EDIT: nvm... Typo in launch.json

  • @user-ep2cs4tt1z
    @user-ep2cs4tt1z ปีที่แล้ว

    can you please make a tutorial with docker django in pycharm please?

    • @LondonAppDeveloper
      @LondonAppDeveloper  17 วันที่ผ่านมา

      I'll keep this in mind while we plan content. Thanks for the suggestion.

  • @big-toni
    @big-toni 3 ปีที่แล้ว

    thanks for the video !!

  • @denishempel
    @denishempel 2 ปีที่แล้ว

    The video has already helped me a lot to find out how to debug Django via Brake Point. I usually use C# :D
    I have not made your version adjustments on my system. I also started Docker via Visual Studio Code. Otherwise I always got some kind of error messages.
    Thanks a lot for your video. Now I am one step closer to debugging NetBox plugins. :)

  • @MukundPatel
    @MukundPatel 3 ปีที่แล้ว

    Hi Mark!
    I completed your course of Django Advance in udemy
    How to make that exiting project to run in VS code debug mode?
    and I found issue that I have to user from app.core.models import Recipe
    to get auto suggestion from VS code which lead to give error in project so I need to remove app. from it how to solve that also

    • @LondonAppDeveloper
      @LondonAppDeveloper  3 ปีที่แล้ว

      Hmm good question... You can probably use the same Dockerfile with a few changes.

  • @damianofranco2
    @damianofranco2 3 ปีที่แล้ว +1

    Thank you very usefull! but it doesn't reload the code when modified as it happen outside the docker. Is there a way to get the code reloaded during debugging?

    • @noyoutube4168
      @noyoutube4168 2 ปีที่แล้ว +1

      mount the working directory with the volume in the container

  • @alejandrotraver8744
    @alejandrotraver8744 3 ปีที่แล้ว

    Hi Mark! In your Udemy course (django rest framework with TDD) you use an django command for wait for db, necessary for start up the server. How can we include more commands or previous commands before run server at launch.json or tasks.json? Thanks!

    • @LondonAppDeveloper
      @LondonAppDeveloper  3 ปีที่แล้ว

      You can add more commands by creating new modules in the management/commands/ directory... So if you wanted a command called "import_data", you would copy the "wait_for_db.py" contents and name it "import_data.py"..

    • @alejandrotraver8744
      @alejandrotraver8744 3 ปีที่แล้ว

      @@LondonAppDeveloper The problem I have is launching the command runserver in debug mode. The problem I have in recipe-app is that server starts without waiting database, getting an error. Then I think is needed launch wait_for_db command before runserver in the debugger configuration but I don't know how.

    • @lukaszremkowicz2798
      @lukaszremkowicz2798 2 ปีที่แล้ว

      @@alejandrotraver8744 Did you solved this problem? What kind of error did you have?

  • @JuanFlores-il4yv
    @JuanFlores-il4yv 2 ปีที่แล้ว

    No, I will not debug django like this, it is too complicated.

  • @aksarmaama297
    @aksarmaama297 2 ปีที่แล้ว

    U,,,