S
S
Stanislav Shabalin2020-09-22 23:43:21
Django
Stanislav Shabalin, 2020-09-22 23:43:21

Is it possible to override the save method for all models?

Tell me, is it possible globally in one place to override the save method for all created models?

The essence is the same for everyone: I convert the slug through slugify and the code is repeated in each model

Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Bragin, 2020-09-23
@Starck43

Create an abstract model that will contain the recurring functionality.
Where necessary, inherit from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question