
Django → Django MPTT вывод дерева категорий
Здраствуйте похоже я так и не понял всю суть Django-MPTT батарейки. Так как не могу решить простую задачу с выводом категорий. По этому обращаюсь к вам за помощью.
Начну с начала. Изначально я пытался сделать древовидную структуру просто в Django, но просидев до утра понял что оно того не…

Django → Django - Tutorial 058. Database Growth Due to django_session Table
Django, Postgres, garbage collection, Python, PostgreSQL
Lately, I have noticed that the fatal moment is approaching, when the disk space for the site on the hosting will catastrophically cease to be enough. And the database dump becomes incredibly huge, although there are no obvious prerequisites for this. The content size of the site isn't growing that fast, and the number of registered users isn't growing that fast either.
After examining the database, it was found that the size of the django_session table is just a gigantic almost 7 GB, and the size of the index also reaches almost 6.5 GB, despite the fact that the size of the database itself is 14 GB.
At the same time, the size of the second largest table is only 11 MB and this is a third-party application with a list of cities. And the size of the third table, which contains messages on the forum, is only 8 MB.
Accordingly, it was decided to figure out why this is happening and how to fix it.
Right now, I probably won’t reveal anything new to those who actively administer PostgreSQL databases, but for beginners and those who mainly deal with Django as a PET project, without professional use, the information may be useful.

Django → Получить текущего пользователя в своём менеджере модели
Здравствуйте!
В общем суть вопроса вроде как ясна из заголовка.
Допустим у меня есть модель Article
class Article(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, default=User) title = models.CharField('Title', max_length=50) ........ …

Django → Django - Lesson 057. Multilanguage support in MarkdownField with auto populate functionality
MarkdownField, markdown, modeltranslation, Django
The article How to write auto populate field functionality described the simplest functionality of the MarkdownField field to support markdown syntax on a site with automatic generation of html content.
I did not immediately show advanced functionality to make it easier to understand what a Markdown-like field is like. But now I would like to expand this functionality to add support for multilingualism.

Django → Django - Tutorial 056. How to convert image to WEBP format when saving to ImageField
ImageField, Django, WEBPField, webp, Python
WEBP is an image compression format that was introduced by Google in 2010. Its main advantage is its low size without visible loss of quality compared to formats such as JPEG or PNG. Therefore, it is quite logical to use this format for storing images on the site, especially if you do not need to store the original images on the site.
After a long search, I still did not find a ready-made and simple solution that would support converting images to WEBP format on the fly.
Therefore, I decided to write my own version, which eventually consists of a couple of dozen lines and is as simple as a wooden board.

Django → Django - Tutorial 055. How to write auto populate field functionality
field, Django, python, auto, Python
For a long time I wanted to write an article on how to write auto populate field functionality for a Django project. This is a very useful feature that allows you to change the content of other model fields in Django by setting a value to a field that uses auto populate.
First, why is it needed? - Such functionality allows you to reduce the size of the code in those places where you need to rewrite other fields of the object when they change. That is, for example, you do not have to redefine the save method each time in order to rewrite some field in case other fields of the object change. Also, using auto populate is basically a more advanced and neat way to manage data models in Django.
And also a similar approach can solve some problems and improve the site.
Django → Django template forloop counter change design after x article

Django → Parameter "form" should contain a valid Django Form
День добрый.
Делал по уроку "Django - Урок 017. Кастомизированная страница авторизации на Django" форму авторизации и натолкнулся на вот такую ошибку в login_widget.html:
Parameter "form" should contain a valid Django Form
Жалуется на строку:
…{% bootstrap_form login_form %}

Django → Как создать форму для загруженных изображений
День добрый.
Есть приложение, которое позволяет загрузить несколько изображений на сервер. Как создать форму для внесения описания к каждому из загруженных изображений? Хотелось бы, чтобы результат выглядел так:
<form ...> <img src="img1.jpg"> <input type="text"…
Django → Не работает код на статус онлайн
При попытке добавить код для статуса как встатье, я сталкнулся с проблемой, что он не записывает данные в бд(поля last_online NULL), такое ощущение, что бек просто не работает. Можете подсказать как это исправить?
Версия Django 3.1.6
Версия питона 3.8.2
Модель юзера
from djan…
Fornex
Let me recommend you a great European Fornex hosting.
Fornex has proven itself to be a stable host over the years.
For Django projects I recommend VPS hosting
Following the link you will receive a 5% discount on shared hosting services, dedicated servers, VPS and VPN
View HostingShare on social networks
Donate
The EVILEG project has switched to a non-commercial basis and will develop solely on the enthusiasm of the site creator, the enthusiasm of users, donations and the hosting referral system
Thank you for your support
Available ways to support the project
PayPal
PatreonYandex.MoneyMore