Advanced search
Evgenij LegotskojFeb. 8, 2022, 5:55 p.m.

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

Evgenij LegotskojAug. 22, 2019, 1:42 p.m.

C++C ++ 17 - Lazy template functor with caching heavy function computation result

lambda, functor, C++17, auto

Developing the idea of caching the result of calculations of heavy functions , I propose to write a small template class, which will take the function as an argument, namely the lambda function, as the most universal an instrument within which a heavy function will be performed.

In this case, the result of the function will not be calculated at the time of creation of the Functor, but at the time of calling the operator parentheses () . And at the same time, the result will be cached. That will allow not to call a heavy function more than once as part of the execution of a method.

Evgenij LegotskojAug. 21, 2019, 3:45 p.m.

C++C++14 - lambda function with cached return value

C++14, lambda, auto, cache, C++

Suppose we wrote a function that calculates some value or uses a function to calculate this value, while the function_ which calculates the value is quite expensive to calculate and works for a long time. In this case, we call the lambda function several times in some code.

To avoid multiple calls to the heavy function, we can cache the value that the heavy function returns.

Evgenij LegotskojAug. 21, 2019, 1:56 p.m.

C++C++14 - unnamed structure as auto value returned by function

lambda, C++, C++14, auto

Let's look at an interesting construction from the C++14 standard, which allows you to return the structure used in one place of the code, but you need to return an object with named fields.

Such a construction can serve as a replacement for std::tuple. At the same time, we will not need to declare any additional structures that we are not going to transfer anywhere, since we need to get only a set of data that we will somehow use immediately at the place of return and will not transfer further in the same form.

Evgenij LegotskojMay 12, 2017, 11:06 p.m.

C++C++ - Tutorial 002. Types, Variables and Arithmetic

C++, int, char, double, auto, nullptr

Each variable or expression has its own data type, for example, an declaration

int some_variable;

Indicates that the variable some_variable has an integer type int .

The declaration allows you to enter a variable in the program. This variable will have a certain type of data: integer, floating point, character in the case of basic data types, or custom type (data structure, class). The type of the variable defines the set of operations that can be performed on the variable. The declaration of a variable determines the allocation of the memory area that is required for it. And also the value of this variable, which from the computer's point of view will be a sequence of bits. The declaration of a variable also carries the name by which the programmer will refer to this variable in the program code.

In the above example, we have a variable that has a base integer type, with which arithmetic operations, comparison, assignment, etc. can be performed. Refer to the code in this code by this name by some_variable.

Card image cap
Pulsum Via

Project for travelers from EVILEG.


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 Hosting
Share on social networks

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



C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10

C++ - Test 005. Structures and Classes

  • Result:83points,
  • Rating points4

C++ - Test 002. Constants

  • Result:58points,
  • Rating points-2
Last comments

Android and QML - Adding Splash Screen

Интересен формат иконки, если это png, то как решается проблема scalability? не растягивается ли лого на китайфонах с 1280х2500? У меня просто сплеш скрин с градиентом и логотипом, и вот несколь…

Qt/C++ - Lesson 023. Moving QGraphicsItem on QGraphicsScene with mouse help

FIGURE Abdominopelvic regions. Zjuaqd - Cialis Cialis Recommendations for preparing children and adolescents for invasive cardiac procedures a statement…

How to use nested forms in Django

Спасибо за полезную статью. Подскажите пожалуйста, что делать если нужно реализовать большее количество вложенных форм? Например если на модель Address ссылается fk другой модели, на котору…

Qt/C++ - Lesson 051. QMediaPlayer – simple audio player

Не думаю, QMediaPlayer в один поток проигрывает. Если вам нужно одновременное воспроизведение нескольких аудиоисточников, то вам нужна Bass audio library , насколько знаю, её обычно и…

Qt/C++ - Lesson 051. QMediaPlayer – simple audio player

есть такая вообще возможность ?
Now discuss on the forum

Sorting the added QML elements in the ListModel

I am writing an alarm clock in QML, I am required to sort the alarms in ascending order (depending on the date or time (if there are several alarms on the same day). I've done the sorting …

Изменение поведения QGroupBox при клике на его чекбокс

Я вынес виджеты вынес за пределы QGroupBox в итоге.

QSqlRelatipnalTabelModel Qt 4.8.1 как получить id внешней связи?

Есть еще принципиально другой вариант решить раз и навсегда вопрос с полей id внешней связи. Это форкнуть Qt 4.8.1 QSqlTableModel, то есть создать свою ветку развития. Например создадим кл…

Добавление AndroidManifest.xml в cmake

Добрый день. Как добавить AndroidManifest.xml в cmake? Это не работвет set(ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android CACHE INTERNAL "")set(ANDROID_BUID_DIR ${CMAKE_C…

Событие wheelEvent для виджета QLineEdit

вот что получилось: from PyQt5 import QtCore, QtGui, QtWidgets class LineEdit(QtWidgets.QLineEdit): def wheelEvent(self, event): #print("_") delta = 1 if e…
© EVILEG 2015-2022
Recommend hosting TIMEWEB