Тёмный

Django Deployment: How to deploy Django app to server using Nginx + Uvicorn | Django deploy tutorial 

Red Eyed Coder Club
Подписаться 16 тыс.
Просмотров 7 тыс.
50% 1

This Django Deployment to server video is about how to deploy Django project with Vue.js static files (that are generated by Webpack) to a remote server using Nginx, PostgreSQL and Uvicorn.
In this Django Deployment Tutorial I use an Ubuntu Server 20.04 that is running an a Virtual Machine instead of VPS, but actually it doesn't matter, because it's the same Ubuntu.
To deploy Django project on server I used Supervisor - the process manager, that is responsible for starting and restarting of the Django project.
Also with Django I used Uvicorn instead of GUnicorn. Uvicorn is the WSGI (ASGI) interface between the Nginx and Django. I didn't use GUnicorn here because Django 3 is asynchronous framework, and as for now it's a bit tricky to use the Gunicorn with it. So I use Uvicorn for Django.
This "Deploy Django to a server" video is a continuation of the Django Vue.js Integration for Production:
• Django Vue.js Integrat...
And it's idea is to show that the video about Integration is a working way of doing things.
Follow me @:
Telegram: t.me/red_eyed_...
Twitter: / codereyed
Facebook: redeyedc...
Links:
Django deployment checklist: docs.djangopro...
Gist with vue.config.js:
gist.github.co...
Gist with commands to deploy Django project to a server:
gist.github.co...
Timecodes:
[ Creating Django project with Vue.js ]
01:06 - What you need from VPS provider to deploy Django via SSH
02:39 - Creating a Django project, virtual environment
04:30 - Creating a Vue.js app
04:54 - Creating Django templates, static folders
06:03 - Creating Django base, index templates
07:27 - Vue.js index.html file content
08:57 - Django index.html content
09:53 - Django urls.py and view
10:40 - Webpack configuration - vue.config.js
11:20 - Test of Django + Vue.js integration
[ Prepare Django for deployment]
13:37 - Deploy Django preparation
14:08 - Installing python-dotenv, psycopg2
15:16 - Creating of .env, updating settings.py
16:43 - STATIC_ROOT, STATICFILES_DIRS
19:00 - Git repository initialization
[ Server Configuration ]
21:06 - Server configuration beginning
25:14 - Installing system packages
26:09 - PostgreSQL configuration
29:14 - Cloning Django project on server
29:47 - Creating a virtual environment, Installing Django dependencies
31:27 - settings.py PostgreSQL configuration
33:47 - collectstatic
34:20 - Installing Uvicorn, and checking connection to Django
36:34 - Supervisor configuration
41:22 - Nginx configuration
45:22 - Set ALLOWED_HOSTS
45:50 - Fixing the Nginx paths
➥➥➥ SUBSCRIBE FOR MORE VIDEOS ➥➥➥
Red Eyed Coder Club is the best place to learn Python programming and Django:
Subscribe ⇢ / @redeyedcoderclub
Django Deployment: How to deploy Django app on server using Nginx + Uvicorn | Django deploy tutorial:
• Django Deployment: How...
This video is about how to deploy Django project on server.
#deploydjango #djangodeployment #deploydjangoonserver #django #redeyedcoderclub

Опубликовано:

 

7 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 73   
@Time2paw
@Time2paw 2 года назад
Спасибо за раскрытие такой обширной темы. Посмотреть еще не успел, но уверен всё на высшем уровне. Удачи в начинаниях!
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you! Have a nice day.
@jangabow2676
@jangabow2676 Год назад
Thanks a lot! I've been stuck with the deployment for a whole day. After finding your video i managed to deploy my server in half an hour. Im am very thankful for your video!
@RedEyedCoderClub
@RedEyedCoderClub Год назад
Thank you very much!
@Laldiify
@Laldiify 2 года назад
Спасибо! Все работает и все понятно. Такой вы Молодец. Такая РАБОТА!!! Я с вашими работами знакома на русском. Но и на английском воспринимаю почти также, хотя английский у меня слабый. Благодарю.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Спасибо большое. Рад, что вам нравится.
@user-ep1rd5pw1w
@user-ep1rd5pw1w 2 года назад
At first it seems complicated and confusing, but after you delve into it, everything becomes clear and accessible. I will definitely try soon!
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you!
@ashfaquealam3033
@ashfaquealam3033 2 года назад
Thanks a lot, bro. It's the perfect deployment video I've ever seen which covers Django with Nginx and Uvicorn.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Nice! Thank you for the comment!
@abrikosa717
@abrikosa717 2 года назад
Thank you very much! It's what I was looking for. You have many valuable content on your channel
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you! Have a nice day :)
@aurusbr
@aurusbr Год назад
Your video helped me a lot. Thank you!
@RedEyedCoderClub
@RedEyedCoderClub Год назад
Thank you
@user-wj4ky3iu1k
@user-wj4ky3iu1k 2 года назад
Thanks for the Django deployment guide
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you!
@kostya9169
@kostya9169 2 года назад
An excellent educational video on deploying Django.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you very much for your comment! Have a nice day!
@dodokwak
@dodokwak 2 года назад
Special thanks for 14:31. I use mostly /etc/config.json tokep my variables safe but this is another way for doing that.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
You're welcome. But one caveat - python-dotenv can't interpret False or True correctly. It always convert it to 'False' for example, that will be interpreted by Python as True.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
What video should I make next? Any suggestions? Write me in comments! Follow me @: Telegram: t.me/red_eyed_coder_club Twitter: twitter.com/CoderEyed Facebook: fb.me/redeyedcoderclub *ATTENTION* Webpack changed something. Change a bit the config: devServer:{ devMiddleware:{ writeToDisk : filePath => filePath.endsWith("index.html"), headers: {"Acess-Control-Allow-Origin":"*"}, publicPath: "localhost:8080", }, hot: 'only', writeToDisk is now inside devMiddleWare which is inside devServer, hotOnly: true now is hot:'only' and change path to publicPatch *Timecodes:* [ Creating Django project with Vue.js ] 01:06 - What you need from VPS provider to deploy Django via SSH 02:39 - Creating a Django project, virtual environment 04:30 - Creating a Vue.js app 04:54 - Creating Django templates, static folders 06:03 - Creating Django base, index templates 07:27 - Vue.js index.html file content 08:57 - Django index.html content 09:53 - Django urls.py and view 10:40 - Webpack configuration - vue.config.js 11:20 - Test of Django + Vue.js integration [ Prepare Django for deployment] 13:37 - Deploy Django preparation 14:08 - Installing python-dotenv, psycopg2 15:16 - Creating of .env, updating settings.py 16:43 - STATIC_ROOT, STATICFILES_DIRS 19:00 - Git repository initialization [ Server Configuration ] 21:06 - Server configuration beginning 25:14 - Installing system packages 26:09 - PostgreSQL configuration 29:14 - Cloning Django project on server 29:47 - Creating a virtual environment, Installing Django dependencies 31:27 - settings.py PostgreSQL configuration 33:47 - collectstatic 34:20 - Installing Uvicorn, and checking connection to Django 36:34 - Supervisor configuration 41:22 - Nginx configuration 45:22 - Set ALLOWED_HOSTS 45:50 - Fixing the Nginx paths Help the channel grow! Please Like the video, Comment, SHARE & Subscribe!
@kostya9169
@kostya9169 2 года назад
Thank you very much for the interesting and informative video.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you!
@mohamedhamza6276
@mohamedhamza6276 2 года назад
This helped me a lot, thank you and keep it up!
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you!
@yashinshekh802
@yashinshekh802 Год назад
its amazing.. you are genius. would it be possible to make it simple using docker?
@zakchips
@zakchips 2 года назад
Thanks. Great job.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thanks for watching. It's not what you wanted, but I hope it will help.
@zakchips
@zakchips 2 года назад
@@RedEyedCoderClub Don't know why, but my previous comment disappeared. Just to let you know that it was exactly what I wanted. Thank you again.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
It's great!
@nachoBikeLife
@nachoBikeLife 2 года назад
Thanks man🙏🏻🙏🏻🙏🏻
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you for the comment!
@amrmzkr
@amrmzkr 11 месяцев назад
how do you handle routing? do we create pages on django side and each of the page will go to vue?
@FernandoTaladriz
@FernandoTaladriz 2 года назад
Hello I have this error (vue.config.js) when running npm run serve, does anyone know how to fix it? ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - Options has an unknown property 'writeToDisk'.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Webpack changed something. Change a bit the config: devServer:{ devMiddleware:{ writeToDisk : filePath => filePath.endsWith("index.html"), headers: {"Acess-Control-Allow-Origin":"*"}, publicPath: "localhost:8080", }, hot: 'only', writeToDisk is now inside devMiddleWare which is inside devServer, hotOnly: true now is hot:'only' and change path to publicPatch (many thanks to Leoncio Ferreira for valuable comment)
@Dima-qz4su
@Dima-qz4su 2 года назад
Спасибо бро
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thanks for watching!
@syedmahbubulhuda6762
@syedmahbubulhuda6762 2 года назад
Facing this problem: ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options has an unknown property 'writeToDisk'. These properties are valid: object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? } Any help?
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Check your code please
@alexanderdecember8743
@alexanderdecember8743 20 дней назад
Unfortunately, the video is not actual on 2024. Could you be so kind as to update it to the present time - the information and deployment scheme are great and superbly useful. Don’t want to let it rest in peace for ages.
@RedEyedCoderClub
@RedEyedCoderClub 20 дней назад
It's actual on 2024. I use this scheme on production.
@alexanderdecember8743
@alexanderdecember8743 20 дней назад
@@RedEyedCoderClub все работает до момента создания бандла. После его создания, не может загрузить файлы из статики. Действую по шагам
@alexanderdecember8743
@alexanderdecember8743 19 дней назад
@@RedEyedCoderClub Please show the actual vue.config.js, I think that's the reason.Thanks in advance
@alexanderdecember8743
@alexanderdecember8743 19 дней назад
@@RedEyedCoderClub This config file worked for me: module.exports = { publicPath: process.env.NODE_ENV === 'production' ? '/static/dist/' : 'localhost:8080', outputDir: '../backend/static/dist', indexPath: '../../templates/base-vue.html', devServer:{ devMiddleware:{ writeToDisk : filePath => filePath.endsWith("index.html"), headers: {"Access-Control-Allow-Origin":"*"}, publicPath: "localhost:8080", }, hot: 'only' } }
@RedEyedCoderClub
@RedEyedCoderClub 19 дней назад
the Vue.js part doesn't work. Ok, got it
@slk1052-x6c
@slk1052-x6c 2 года назад
Question about this - If I have constant api calls running with celery, what are the steps to deploy?
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
I can't explain it in comments. Try to configure Supervisor to start Celery beat. Or may be I'll make the video about it.
@slk1052-x6c
@slk1052-x6c 2 года назад
@@RedEyedCoderClub Thanks so much a video would be extremely helpful!
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
I'll try to do it
@slk1052-x6c
@slk1052-x6c 2 года назад
​@@RedEyedCoderClub Hey have you been able to do it?
@gamesday1695
@gamesday1695 2 года назад
Could you share about how to login Linux server using ppk file and with only ip
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
May be next time
@gamesday1695
@gamesday1695 2 года назад
@@RedEyedCoderClub Tomorrow
@gamesday1695
@gamesday1695 2 года назад
Please
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Actually I got plans for tomorrow.
@lilia1923
@lilia1923 2 года назад
I followed all your codes but it doesn't work
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
What does it mean "doesn't work" - what's happening? Check your actions and the code please. Everything is quite simple
@ibrahimoglu
@ibrahimoglu 2 года назад
👍
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
Thank you!
@alperaslan.
@alperaslan. 2 года назад
When i migrate (33:35) throw this error django.db.utils.ProgrammingError: column c.relispartition does not exist LINE 5: WHEN c.relispartition THEN 'p' Normally i use db.sqlite locally my project done .
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
What version of PostgreSQL are you using?
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
I guess you need either to downgrade Django to 3.2 or upgrade PostgreSQL to 10 or higher (14.4 the current one)
@alperaslan.
@alperaslan. 2 года назад
@@RedEyedCoderClubI build my project with 4.0 Django and sqlite . I install on server postgresql. in pip freeze version of psycopg2 2.9.3. I create db on postgresql and change the db info. when i migrate doesnt work. My db is empty on server. And i have older migrations file on my project migrations folder. And i checked my postgresql version is 9.5 and i changed the version 13.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
To get the version of Postgres you can use the `psql --version` command. If you use Django 4 the PostgreSQL version should be 10 or more. Also try to drop the table, delete migrations, and make migrations again. Also look at django_migration table in your DB, drop it too.
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
It's great! Yep, you can use uvicorn for static website. Configuring gunicorn for Django 3+ is a bit complicated, due to asynchronous support in Django.
@Evervess179
@Evervess179 2 года назад
Блин почему не записываешь на русском =)
@RedEyedCoderClub
@RedEyedCoderClub 2 года назад
А зачем?
Далее
Bike Challenge
00:20
Просмотров 21 млн
БЕЛКА РОЖАЕТ?#cat
00:22
Просмотров 621 тыс.
Django | Server Setup (WSGI, Gunicorn, Nginx)
9:37
Просмотров 145 тыс.
Prepare a Django app for Deployment using Docker
39:10
API Testing Using Postman | Crash Course
3:27:51
Просмотров 92 тыс.