The Django docs only list examples for overriding save() and delete(). However, I’d like to define some extra processing for my models only when they are created. For anyone familiar with Rails, it would be the equivalent to creating a :before_create filter. Is this possible?
The Django docs only list examples for overriding save() and delete() . However, I’d
Share
Overriding
__init__()would cause code to be executed whenever the python representation of object is instantiated. I don’t know rails, but a:before_createdfilter sounds to me like it’s code to be executed when the object is created in the database. If you want to execute code when a new object is created in the database, you should overridesave(), checking if the object has apkattribute or not. The code would look something like this: