Тёмный

Writing Maintenance Mode Middleware in Django (with tests)! 

BugBytes
Подписаться 27 тыс.
Просмотров 1,9 тыс.
50% 1

In this video, we'll learn how to write a custom middleware that allows us to put our Django app into Maintenance Mode.
We'll also write Django Tests for the functionality provided by the middleware class!
☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
ko-fi.com/bugbytes
📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:34 Django Middleware overview
03:59 Defining Maintenance Mode middleware
10:29 Add Django tests for middleware
𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
📖 Blog: bugbytes.io/posts/
👾 Github: github.com/bugbytes-io/
🐦 Twitter: / bugbytesio
📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Django Middleware: docs.djangoproject.com/en/5.0...
Django Tests: docs.djangoproject.com/en/5.0...
#python #django #webdevelopment

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

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 31   
@bugbytes3923
@bugbytes3923 2 месяца назад
Check this video to learn how to re-write these tests with Pytest! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-pdatgYDXmSE.html
@kimuyu
@kimuyu 2 месяца назад
Excellent tute as usual. If you could look into manually rendering inlineformsets with , that would be a hit.
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks! I'll have a think about that one.
@francoisschoeman5350
@francoisschoeman5350 2 месяца назад
Great vid, thanks! I would also love a video about both using and creating webhooks... Pleeeeezzz....😁
@bugbytes3923
@bugbytes3923 2 месяца назад
Haha great suggestion. I'll have a look at webhooks in the near future.
@iwswordpress
@iwswordpress 2 месяца назад
Tests are a great bonus!
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks!
@aminzahedsadeghi4995
@aminzahedsadeghi4995 2 месяца назад
Thanks a lot for this great Django course 🤩. Please make a video about async ORM and async views in Django, and how we should integrate Django ORM with our views and when we should use it. This is content that I don't see any good sources for.
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks! Great suggestion, will do so in the future.
@hipertracker
@hipertracker 2 месяца назад
Good job. You could add also pytest example..
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks! I'll add a quick follow up video for the pytest example.
@AmoahDevLabs
@AmoahDevLabs 2 месяца назад
This is really informative. Thanks for sharing.
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks very much, glad it was helpful!
@aashayamballi
@aashayamballi 2 месяца назад
thank you!
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks!
@serychristianrenaud
@serychristianrenaud 2 месяца назад
Thanks 👍
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks for watching!
@frameff9073
@frameff9073 2 месяца назад
good thank
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks for watching!
@Septumsempra8818
@Septumsempra8818 2 месяца назад
1:31 Could we do some vids on strategies for updating data of a production site? How best do we change a large portion of our data (80%) without affecting performance?
@bugbytes3923
@bugbytes3923 2 месяца назад
I think that'd be interesting, for sure - I'll have a look into it. Thanks!
@Peterstavrou
@Peterstavrou 2 месяца назад
Another amazing video! When checking if a variable has been set in settings, do you usually use if settings.MAINTENANCE_MODE or if hasattr(settings, 'MAINTENANCE_MODE ') and settings.MAINTENANCE_MODE is not None? Which is best practice to use?
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks Peter! Your example there is a better suggestion, for sure. Use hasattr(settings, 'MAINTENANCE_MODE') and settings.MAINTENANCE_MODE is not None - to ensure that the value is defined in the settings before accessing it.
@estersone
@estersone 2 месяца назад
Make video about integrating django with ML
@_russell
@_russell 2 месяца назад
When you doing a video on `django-components`?
@bugbytes3923
@bugbytes3923 2 месяца назад
Preparing it now! Just ironing out a few details but it should be out this month.
@TheNerdyPlayer
@TheNerdyPlayer 2 месяца назад
Would it be possible to do this without restarting the server? For example reading the value from cache in the middleware or at this point it's just easier to do it with nginx or something. Very cool video gave me tons of ideas to test out myself. :) much love
@georgejoseph2601
@georgejoseph2601 2 месяца назад
Just run django inside a docker container
@TheNerdyPlayer
@TheNerdyPlayer 2 месяца назад
@@georgejoseph2601 how would running a docker container prevent the need to restart the webserver? im not talking about the whole linux server my dude
@bugbytes3923
@bugbytes3923 2 месяца назад
Thanks for the comment! You could indeed set this value in the database or the cache, and the Middleware could read the value from that source instead of just the settings. The MAINTENANCE_MODE value could then be updated via the Django Admin or some other mechanism. With that setup, no need to stop/restart the server, I don't think!
@georgejoseph2601
@georgejoseph2601 2 месяца назад
@TheNerdyPlayer running Django within a slim python/alpine docker container allows changes to settings files to propagate without an explicit restart while you test things out. Just an option
Далее
Клип Уже На Канале #янгер #shorts
00:15
치토스로 체감되는 요즘 물가
00:16
Просмотров 1,1 млн
Stop Writing So Many Tests
10:02
Просмотров 82 тыс.
The Rust Standard Library is SO Confusing...Until Now!
11:45
GeneratedField in Django 5 - New Django Model Field!
23:19
Клип Уже На Канале #янгер #shorts
00:15