A tutorial on how a Django project runs in development and production environments. I also show how to run a Django project using a WSGI server (Gunicorn) and a web server (Nginx).
its funny that such an important concept its never explained in other channels, they can talk about django all day long, but fail to explain the professional way of deploying apps
@@djangoroad read: you are looser. Do you know why you stopped... creating the content? I was going to write this but you are not my slave. !00 and 2 o/o. that's your choice great videos mam. I pray you will come back not for us but .....
I've watched 10 videos on this topic so far and some of them were 50 mins long "in the name of explaining in details" but this brief and well done video was the best and the clearest so far.
I had been struggling following the gunicorn docs and understanding the relation between Nginx-Gunicorn-Django, then I found your video that put it all together very succinctly. Thank you for the time and effort you took to make the video and post it on you-tube. Your effort has been greatly appreciated and helped me greatly. Thank you.
Such a simple and clear tutorial ! I have not seen another Django tutorial that explains the concept in such a clear way. Thank you for creating this video.
Hope to cover this topics too: Django with lambda, Scaling Django with Docker, Kubernet Django with S3 Bucket Django with RDBMS (handle/Fetch data from the different database) cover with AWS.
This tutorial is bang on the money. I've followed an hour long video and not got it working, this last 9 mins and DOES work. Brilliant. If you get a chance could you do one on setting up SSL and port 443 with Django on a production site? Thank you Dot JA 🙂
It's so rare that I click like on a video, but wow this was a great video. Had to go seerching in my apps UI to even find the button. Thank you for the explanation.
In my organisation, our huge django application is configured with both gunicorn and nginx as web server. I had so many confusions in the configuration coupling. Now I have a clear picture after watching your explanation. And one more thing, I would like you to make a similar video on nginx proxy server configuration for load balancing django application. As the user base grows, proxy server is the way to scale with proper cpu utilisation. Great video by the way. Keep up the good work. Thanks
Also if you are on a VPS or similar, you need to allow port 8000 on the provider side, e.g. change AWS EC2 inbound rules for your instance to allow custom tcp port range 8000. Otherwise you will keep getting connection refused.
your content is great buddy, just keep patience and continue making useful videos, and you will have huge reach. Thanks again, looking forward for more django and web development related videos.
This was PEAK content! Very well explained. Just one question, I know I'm very late, but why did we need to create a specific route for /static/ in nginx ? What if we don't give it, django anyways is going to handle those right, after we run `collectstatic`?
Thank you for this tutorial. I was struggling to get the final piece with gunicorn setup "pythonpath" and "command" vars were missing. I kept scratching my head as to why the workers weren't spawning. You awesome!!!!!
Great video, thank you! However there's a small mistake at the end (I think), in the Nginx config where you're using "root /home/ubuntu/static", that wouldn't work because it will resolve to home/ubuntu/static/static I suppose it worked at the end because debug was still set to True
Perfect, thanks alot! But, i have a question regarding deploying new services on the same server. Should i do it like that: 1. Deploy new django service in new container qith gunicorn. 2. Edit nginx service to serve both old and new services.
This is excellent, thanks for the tutorial. Got it working on an AWS EC2. Not sure why I did the docker version of this tutorial before this one but whatever
@@Poo1199-c1o Sorry I am not an expert. That makes me think nginx is running and trying to hit gunicorn but gunicorn has an issue. is gunicorn running? i believe it should be: user clicks goes to your web page -> nginx gets request -> request passed to gunicorn -> something goes wrong and 502
thank you so much, I followed a digital ocean tutorial and couldnt get my app to be served, I am wondering why this very simplified approach gets the job done. Is this all the setup I have to do? what are the next steps? thank you so much.
Nice video, thanks. I just wonder what’s the difference or pros and cons between serving statics with WhiteNoise vs serving statics with web server. Although I guess in production for real projects, statics will be serve by a cdn, right ?
Thanks for the feedback! Media files are treated same as static, you can specify the location in the Django configuration as well as the Nginx config. Depending on the traffic you receive to your web app, you might also want to look into S3 for storing this type of content.
At 5:05, what and from where did you copy and paste? I am using a Mac and want to get the correct path for both the `command` and `pythonpath` variables. Thank you!
Thank you for video! But what is your IP in the Nginx config and why do you need to specify it there explicitly? I thought it can be some kind of alias that refers to the primary netrowk interface and assigned IP to it by the network provide.
@@frankstuart6032 remember you have to put path only till the dir which contain wsgi.py file. So that you can use myproject.wsgi in command for example if your wsgi file is located in: home/username/myproject/myproject/wsgi.py your pythonpath should be: PYTHONPATH="/home/username/myproject"
for anyone who might be running into the same problem as I am. I don't know but placing the complete static directory path in my settings.py did not work ( I reference static files using the static tag, that might have something to do with it) what finally worked for me is settings.py: STATIC_URL = '/static/' and in the nginx configuration location /static/ { root {my project path without the '/static/' at the end }; }
its funny that such an important concept its never explained in other channels, they can talk about django all day long, but fail to explain the professional way of deploying apps
That's 1000000000000000....% correct. Come Back Mam, you have things that no one has.
100% bro. amen to that.
Because they don't know themselves.
😆🤌🏻
Digital ocean has blog post on it.
Never seen a django deployment tutorial as explanatory as this. I was totally struggling thanks!!
Thanks, great video! I am learning Django deployment and always get afraid when I hear the terms Nginx and Gunicorn but you made them very clear now!
I'm so glad you understand them better now :)
@@djangoroad read: you are looser. Do you know why you stopped... creating the content? I was going to write this but you are not my slave. !00 and 2 o/o. that's your choice great videos mam. I pray you will come back not for us but .....
Hahaha been there
I've watched 10 videos on this topic so far and some of them were 50 mins long "in the name of explaining in details" but this brief and well done video was the best and the clearest so far.
Wait, I think you dropped this 👑
Great content explained in such an easy-to-understand way. I loved how you broke down the concepts then showed them in practice.
I love you, literally saved me from hours of endless headscratching; I'm new to this so its still pretty daunting to say the least :/
so I'm watching this tutorial 2 years later, and guess what, my testimony still resonates with the many appraisal comments. good work @django road
Thanks!
Thank you from South Korea! I have never seen such a easy-to-understand lecture to get the concept of web server❤
Thanks for the support :)
Clear and simple instructions. Still a great tutorial in 2024!
I had been struggling following the gunicorn docs and understanding the relation between Nginx-Gunicorn-Django, then I found your video that put it all together very succinctly. Thank you for the time and effort you took to make the video and post it on you-tube. Your effort has been greatly appreciated and helped me greatly. Thank you.
Thanks for the comment :) I'm glad you found the video helpful.
Goodluck!
Such a simple and clear tutorial ! I have not seen another Django tutorial that explains the concept in such a clear way. Thank you for creating this video.
Hope to cover this topics too:
Django with lambda, Scaling
Django with Docker, Kubernet
Django with S3 Bucket
Django with RDBMS (handle/Fetch data from the different database)
cover with AWS.
Nice ideas! Thanks
Great points! A resource discussing this would be immensely helpful.
@@SwapnilPhulse +1
This is the simplest explanation I have found thus far. Thank you so much!
Finally a tutorial speaking human language
Nicely explained 🙏
This tutorial is bang on the money. I've followed an hour long video and not got it working, this last 9 mins and DOES work. Brilliant. If you get a chance could you do one on setting up SSL and port 443 with Django on a production site?
Thank you Dot JA 🙂
It's so rare that I click like on a video, but wow this was a great video. Had to go seerching in my apps UI to even find the button. Thank you for the explanation.
Thanks, I appreciate it!
Nice tutorial. Complete, to the point, and, most importantly, correct.
OMG... the way you explained this is so clear... Many thanks really. Now investigating to add more security to the site! Cheers!
Thanks for the video, I have got it running.
Very good, it is the easy way that you show about how to deploy django app.
Thanks mam, my first deployment done seamlessly.
In my organisation, our huge django application is configured with both gunicorn and nginx as web server. I had so many confusions in the configuration coupling. Now I have a clear picture after watching your explanation. And one more thing, I would like you to make a similar video on nginx proxy server configuration for load balancing django application. As the user base grows, proxy server is the way to scale with proper cpu utilisation.
Great video by the way. Keep up the good work. Thanks
I get a 502 Bad Gateway error. I tried to fix it for the last couple of days and I can't. Does anyone have any idea how to solve it?
God bless you! 3 years old video and still the best one over YT))
Also if you are on a VPS or similar, you need to allow port 8000 on the provider side, e.g. change AWS EC2 inbound rules for your instance to allow custom tcp port range 8000. Otherwise you will keep getting connection refused.
Thankyou very much for making this fantastic video, this video helped me setup my first website with django, still relevant after 2 years, thanks.
exactly what I was looking for. I have to install Django on a server on an intranet. this came in very handy
Marvelous explanation!
Excellent video. Please make one on how to deploy multiple django sites on 1 server using this.
your content is great buddy, just keep patience and continue making useful videos, and you will have huge reach. Thanks again, looking forward for more django and web development related videos.
I've just come to your channel, great content, but believe there is a lot u can offer to the community, keep It up.🥰
This was so helpful, thank you so much
thank you so much, your videos are amazing, simple and direct to the point with clear explanation.
Thank you so much for making this video. After days of me constantly failing, you realy helped me out!
Great video! Simple deomonstration of the tool :)
One note: in my case, isntead of "root" I needed "alias" for the static files (location /static/)
thank you very much - جزاکم اللہ احسن الجزاء
Thanks.It is so easy understandable for me than other videos.
Wow, that was a masterpiece of explanation! Thank you 🙏
It was a very direct explanation and simple, but it's straight to the point. I liked it. Thank you :)
This was PEAK content! Very well explained. Just one question, I know I'm very late, but why did we need to create a specific route for /static/ in nginx ? What if we don't give it, django anyways is going to handle those right, after we run `collectstatic`?
Thank you for this tutorial. I was struggling to get the final piece with gunicorn setup "pythonpath" and "command" vars were missing. I kept scratching my head as to why the workers weren't spawning. You awesome!!!!!
Hey make more of these deployment type videos. They are super helpful
Incredible! Super intuitive and well explained. Thank you!!!!
Great video, thank you!
However there's a small mistake at the end (I think), in the Nginx config where you're using "root /home/ubuntu/static",
that wouldn't work because it will resolve to home/ubuntu/static/static
I suppose it worked at the end because debug was still set to True
Thx a lot! Thats a great short video that covers the basics needed 👍👍
One of the best videos I've ever watched. Thanks!
thanks for your video. I have an error "No module named "myproject.wsgi". Any idea to fix it?
You are so awesome, it's so clean, thank you one million times !
I'm trying so hard to setup Django with OpenLiteSpeed and his module LSAPI. If you're looking for a new tutoriel 😅
Thank you very much It is very useful Tutorial
Easy to understand great presentation.
Hi, this is an awesome video! If possible, you should follow this up with how you would integrate certbot.
Perfect, thanks alot!
But, i have a question regarding deploying new services on the same server.
Should i do it like that:
1. Deploy new django service in new container qith gunicorn.
2. Edit nginx service to serve both old and new services.
explanation is so clear, thank you
This was super insightful! Thank you so much. You're the best.
really nice tutorial, looking forward to more videos
thanks :)
very clear and onto the point
thank you!!! you literally save my life lol
Thank you, the best tutorial on the topic
Thank you so much, it was so well explained!
Thankyou so much , for such wonderful explaination.
This is excellent, thanks for the tutorial. Got it working on an AWS EC2. Not sure why I did the docker version of this tutorial before this one but whatever
Hi , did you add ip of EC2 in allowed host ??
@@Poo1199-c1o Yes. It's not good practice but I think you can do ['*'] to allow any host also
@@soffer I am getting 502 error while accessing the instance IP.. do you know how that can be resolved?
@@Poo1199-c1o Sorry I am not an expert. That makes me think nginx is running and trying to hit gunicorn but gunicorn has an issue. is gunicorn running? i believe it should be: user clicks goes to your web page -> nginx gets request -> request passed to gunicorn -> something goes wrong and 502
Thanks, great video!
thank you very much, this is the best explanation
Thanks a lot. That was really helpful. Straight to the point.
Love from India. Keep going ❤️
Super. Thanks from Uzbekistan
Great tutorial I love your teaching method
wow, perfect tutorial, thank you so much
This is just perfect! Thanks alot!
thank you so much, I followed a digital ocean tutorial and couldnt get my app to be served, I am wondering why this very simplified approach gets the job done. Is this all the setup I have to do? what are the next steps? thank you so much.
perfect explained, thank you!
Clearly explained. Thank you.
this finally worked thank you.
Nice video, thanks.
I just wonder what’s the difference or pros and cons between serving statics with WhiteNoise vs serving statics with web server.
Although I guess in production for real projects, statics will be serve by a cdn, right ?
Excellent. Well appreciated. Simple and elegant. ❤️ from Chn Greater Bharat
Clear tutorial ,Keep going ,thanks 👍
Thank you for explanation
Very very obvious and useful. Thanks!
A slick tutorial, well done! Are media files treated the same as static files or is there another configuration needed for production?
Thanks for the feedback! Media files are treated same as static, you can specify the location in the Django configuration as well as the Nginx config. Depending on the traffic you receive to your web app, you might also want to look into S3 for storing this type of content.
This is really great !
Thank You !
very simple and useful 😸 💚💚
Keep going ☺️
hey thanks a ton...this was what i needed
very simple and informative
Thanks from Venezuela!!
Thanks! Great explanation 🔥
Good job 👍 simple and effective
Great tutorial, thanks a lot
wow! straight to the point
At 5:05, what and from where did you copy and paste? I am using a Mac and want to get the correct path for both the `command` and `pythonpath` variables. Thank you!
Thanks, keep going
Thank you for video!
But what is your IP in the Nginx config and why do you need to specify it there explicitly?
I thought it can be some kind of alias that refers to the primary netrowk interface and assigned IP to it by the network provide.
thanks this work with ubuntu 22.04 UEFI on alibaba cloud, with django 5.0
Very clear. Thx for the vid
ModuleNotFoundError: No module named 'myproject.wsgi'
This is the error im getting when im running gunicorn -c conf/gunicorn_config.py myproject.wsgi
Have you specified the correct path (PYTHONPATH) for your project in Gunicorn_config.py.
@@alexdeathway yes
@@frankstuart6032 remember you have to put path only till the dir which contain wsgi.py file. So that you can use myproject.wsgi in command
for example if your wsgi file is located in:
home/username/myproject/myproject/wsgi.py
your pythonpath should be:
PYTHONPATH="/home/username/myproject"
@@alexdeathway thankyou i got it🙏🏽
Do you know if, once you place the static files in the /static/ folder, you have to set some permissions?
for anyone who might be running into the same problem as I am. I don't know but placing the complete static directory path in my settings.py did not work ( I reference static files using the static tag, that might have something to do with it)
what finally worked for me is settings.py:
STATIC_URL = '/static/'
and in the nginx configuration
location /static/ {
root {my project path without the '/static/' at the end };
}
DUDE THANKS it worked for me aswell
You are simply 👏👏😁 awesome
Thank you so much, great job!
crystal clear. Thank you !