
Django → Django - Lesson 059. Saving the selected language in user settings
python, language, translation, django
In this article, I would like to show an example of how you can make a link on the site so that the user can switch between languages on the site.
But I will show a more advanced version of this functionality, namely saving the selected language in the user table, as well as redirecting the user to a page with the correct language that was selected by the user, if they are of course authorized. That is, if the user has set the German language for himself, then when going to the site via an English link, the site will automatically redirect the user to the page with the German language.
To do this, we need to add a language code field to the user model, I hope that everyone is already using their user model in Django instead of the default one.
Rewrite the standard Django language setup function, and also add a Middleware that will process the urls requested from the site.
Among other things, this functionality will be useful in order to generate letters with the correct language for registered users.
This article is based on Django 4 and may not be suitable for older versions of Django.

Django → Подсчет суммы баллов в Django
Создаются вопросы с выбором ответа, в модели решил создать к каждому выбору ответа определенный балл.. Теперь как мне сделать общий подсчет баллов в конце опроса, например по нажатию на кнопку, просто сумма баллов?
На форму выводятся все вопросы из бд
Что-то типо таког…
Django → Прикрутить форму к админ-панели
Доброго времени суток! Прошу помощи прикрутить форму загрузки медиаконтента в админ-панели. Дано:
Модель контента
class MediaItem(models.Model): video = VideoField( upload_to = upload_to, width_field = 'video_width', height_field = 'video_height', …

JavaScript → Cложности с кодом javascript в приёме данных из WebSoket
var ws = "" let btn = document.querySellector('#send') let room = document.querySellector('#room") let input = document.querySellector('#input-message") let room.addEventListener("click", function(e){ if(ws){ ws.close() } ws = new Websocket("ws://"+ window.location.host + "/…

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 → Django create table в разных схемах PostgreSQL
PostgreSQL, migrations, django
всем добрый вечер
есть у меня база postgres у которой есть 2 схемы - public, content .
по умолчанию джанго мигрирует таблицы в схему public
в моделях в классе мета я задал параметр db_table где указал явно название таблицы НО есть одно приложение в моделй которй я задал:
…
Django → Django template forloop counter change design after x article

Django → Отправка картинки в DRF
всем привет
я пишу приложение на drf + jwt + vue front
так как при генерации токена мне надо было отправить вместе с токеном еше какие то данные (last_name, first_name, user_avatar) то я переопределил TokenObtainPairView:
https://dpaste.org/EFWf
и переопредел…
Django → Как сделать счетчик закладок для каждого пользователя
Сделал систему закладок как в статье , всё работает прекрасно, но у меня на сайте в панели меню есть кнопка избранного, где отображается сколько статей добавил в избранное пользователь, как сделать так, что бы он обновлялся так же как общий счетчик в статье
до нажатия на кнопк…

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