Answer the question
In order to leave comments, you need to log in
How, when inserting data into the database, to change them depending on certain conditions?
An event is added to the database. The event has a "Number of visitors" field. There is also a sign "Main event". Events without this sign are, as it were, included in the "Main Event".
When creating a "Main Event", the maximum possible number of visitors is indicated. Events that are not main, when they are created, sort of pinch off visitors from the "Main". Accordingly, the maximum number of visitors decreases or increases when non-core events are deleted.
The task is to store directly in the database the number of visitors remaining at the "Main Event" after the creation or deletion of non-main events.
To work with the database, SQLAlchemy is used, respectively, to the model describing the event table, I want to add functions that correct the value of the "Number of visitors" field when inserting or deleting events without the "Main event" attribute.
Is it correct? If not, why and how should this be implemented? In view functions?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question