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

preview_player
Показать описание

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.

And it's idea is to show that the video about Integration is a working way of doing things.

Follow me @:

Links:

Gist with commands to deploy Django project to a server:

Timecodes:

01:06 - What you need from VPS provider to deploy Django via SSH
02:39 - Creating a Django project, virtual environment
04:54 - Creating Django templates, static folders
06:03 - Creating Django base, index templates

[ Prepare Django for deployment]

13:37 - Deploy Django preparation
14:08 - Installing python-dotenv, psycopg2
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
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:

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

This video is about how to deploy Django project on server.

#deploydjango #djangodeployment #deploydjangoonserver #django #redeyedcoderclub
Рекомендации по теме
Комментарии
Автор

What video should I make next? Any suggestions? Write me in comments!
Follow me @:

*ATTENTION*

Webpack changed something. Change a bit the config:

devServer:{
devMiddleware:{
writeToDisk : filePath => filePath.endsWith("index.html"),
headers: {"Acess-Control-Allow-Origin":"*"},
},
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!

RedEyedCoderClub
Автор

Спасибо за раскрытие такой обширной темы. Посмотреть еще не успел, но уверен всё на высшем уровне. Удачи в начинаниях!

Timepaw
Автор

Thank you very much! It's what I was looking for. You have many valuable content on your channel

abrikosa
Автор

Thanks a lot, bro. It's the perfect deployment video I've ever seen which covers Django with Nginx and Uvicorn.

ashfaquealam
Автор

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!

jangabow
Автор

This helped me a lot, thank you and keep it up!

mohamedhamza
Автор

At first it seems complicated and confusing, but after you delve into it, everything becomes clear and accessible. I will definitely try soon!

eprdpww
Автор

Your video helped me a lot. Thank you!

aurusbr
Автор

An excellent educational video on deploying Django.

kostya
Автор

Спасибо! Все работает и все понятно. Такой вы Молодец. Такая РАБОТА!!! Я с вашими работами знакома на русском. Но и на английском воспринимаю почти также, хотя английский у меня слабый. Благодарю.

Laldiify
Автор

Thanks for the Django deployment guide

wjkyiuk
Автор

Thank you very much for the interesting and informative video.

kostya
Автор

Special thanks for 14:31. I use mostly /etc/config.json tokep my variables safe but this is another way for doing that.

dodokwak
Автор

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'.

FernandoTaladriz
Автор

how do you handle routing? do we create pages on django side and each of the page will go to vue?

amrmzkr
Автор

its amazing.. you are genius. would it be possible to make it simple using docker?

yashinshekh
Автор

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?

syedmahbubulhuda
Автор

Question about this - If I have constant api calls running with celery, what are the steps to deploy?

slk-xc
Автор

Could you share about how to login Linux server using ppk file and with only ip

gamesday
Автор

I followed all your codes but it doesn't work

lilia