Django and DRF
302 subscribers
98 photos
39 files
161 links
Purpose is sharing, spreading knowledge which is most related to the Django and Django Rest Framework(DRF)

You can find in here my
- Articles
- Projects with source codes
- Videos
and another useful stuffs
Download Telegram
Hi guys.
Django Image Optimizer 🍏🍋🍊

This package is very useful to optimize image in your django projects and is simple to configure it.
It allows you optimization by images using TinyPNG or Pillow.
You can introduce with it in this link.
👍1🔥1
https://t.iss.one/shukurdev/1055

In django in the one coolest case will might be used this method 🤩🥳
If you are gonna make SearchView for your project you have to search terms in the any of the models in the application and to do this you search objects by term and you had returned all of object types as separately untill now. So now with this method you will have chance to return results of the objects which you have searched as single keyword which is mean {"key": "value"}.
👆👆👆have showed example in the above image.

p.s: please write comments 😅
🔥1
Use select_for_update() method in Django when you have problem with concurrency.

Agar sizda bir vaqting uzida bir nechta process ni ishga tushirishda muammo bulayotgan bulsa shu method dan foydalanganingiz maqul chuni bu bir process ni yakunlab bulgunicha usha process ni lock qilib turadi va keyin ikkinchi process ga ruhsat beradi.

Link: https://www.sankalpjonna.com/learn-django/managing-concurrency-in-django-using-select-for-update
👍2🔥2
💡 Django Celery Beat is the best package to store tasks which can done as automatically on database. And you can manage all of saved tasks on Django Admin panel and you can create, edit and delete tasks and how often they should run with Periodic Tasks
🫐Pypi package
🍉Source
👍2😁2
Javascript dasturchisi Python code yozsa qanday bularkin deydiganlar uchun Top🍉 examples 🥳
Va bu code ni review qilayotgan men: 😰🥵🤯🤬
P.S: Qanday tilda kod yozsangiz ham har bir tilni uzini qonun qoidalari asosida yozishga harakat qiling please. Sizdan keyingi keladigan dasturchilarni ham ozgina o'ylang, f***, b** kabi so'zlarni eshitmay desangiz 😎
🤣1
Don't move fast to another stack.⚠️
👍4
Read this story from Lahiru Hewawasam on Medium: Link
2
In some cases django devs have one problem with migrations files, so i think the guy who is first met with this issue is gonna delete all of migrations and data in DB. if he does this in the production he will might lost all real data 😰🥴🥶.
Ok WHAT SHOULD IT DO ???
Django has — fake flag which is written with migrate command together like this: python manage.py migrate —fake
It tells to Django that migrations have already applied and not need to run it(DON'T RUN IT).
Actually it creates a row in django_migrations table but not run in the SQL to change table structure.
In one another case if you have multiple migrations file you can delete all of them and use above flag(argument).
Improving API Performance
More
👍3
🔥 I absolutely recommended reading this article to learn more about object serializing way and you realize that which way is the best to serialize in short time.

https://hakibenita.com/django-rest-framework-slow
Architectures
More
Nima uchun Django loyihani serverga joylayotganimizda gunicorn servisidan foydalanamiz ?, Django runserver dan foydalanish mumkinku !?

Bu yangi dasturchilar orasida juda ko'p so'ralgan savol

Bu yerda mening tushuncham:👇

⛔️ Djangoning runserveri Single-Thread:

Ko'p qatorli avtomagistraldan farqli o'laroq, runserver - bu bitta qatorli yo'l ga o'xshaydi. U bir vaqtning o'zida faqat birgina so'rovni tutib(handle) qolishi mumkin, bir vaqtning o'zida bir nechta so'rovlar kelganda navbatlarning paydo bo'lishiga olib keladi. Bu userlar yuqori trafik ostida qolib, javob olish vaqtlari sekinlashishiga olib keladi.

Enter Gunicorn: The Concurrency Hero 💪

Gunicorn production muhitida:

Concurrent Processing: Gunicorn ishchi processlarini yaratadi, har biri mini-django app sifatida ishlaydi. So'rovlar yetib kelgan vaqtda, Gunicorn ishchilarni(workers) bo'lib tashlaydi, processlarga parallel ravishda ishlashga imkon beradi. Va bu sezilari darajada performance ni oshishiga tasir qiladi, ayniqsa og'ir trafik ostidagilar uchun.

Scalability: Gunicorn da trafik talablaringizga mos worker processlarning sonini sozlab quyish mumkin.Bu avtomagistrallarga eng tirband bo'lgan vaqtda qo'shimcha yo'llar qo'shishga o'xshaydi

Production-Ready Features: Gunicorn real loyihalarning deployment jarayoni uchun muhim hususiyatlarni taqdim qiladi, ya'ni quyidahilar:

🔹 Pre-forking - so'rovlarni samarali handle qilish uchun worker proccesslarni qayta ishlatish.

🔹 Ilovani restart qilmasdan uning code larni muammosiz o'zgartirish uchun juda zo'r Reloading.

🔹 Timeouts va workerlarni samarali monitoring qilish scaling uchun.

🔹 Yuqori darajadagi loggin va errorlarni handle qilish kuzatishni yaxshilash uchun.

Gunicorndan foydalangan holatda, siz Django loyihangizni samarali scale qila olasiz, so'rovlarni parallel ravishda handle qilish, va foydalanuvchiga muammosiz yetkazib berish – hatto yuqori o'lchamdagi traffic bo'lgan taqdirda ham.
🔥8
#savol
Access tokenni yaroqlilik muddatini 2 3 yil qilsam ham boladimi. 😢

javob:
haa bo'ladi, lekin bu holatda havfsizlikni o'ylamasangiz ham bo'ladi chunki agar hujum qilishmoqchi bo'lsa 1 2 kunda dasturizni qo'lga olishi mumkin. token dan foydalanmasangiz ham bo'ladi😁 agar 2 3 yil qilmoqchi bo'lsangiz chunki foydasi tegmaydi baribir.