DEV Community

Discussion on: Django Models Anti Patterns

Collapse
 
rishitc profile image
Rishit Chaudhary • Edited

Really interesting article!

I had a question: In the example shared describing the replacement of signals with overriding of the save() method:
How do we implement a similar approach to decrement the number of articles written by an author, in the case where a post is deleted by an author?

Thanks

Edit: Fixed markdown syntax

Collapse
 
thearjun profile image
Arjun Adhikari

For that we can use the delete() model method, and create the _delete_post_writing and decrement the count.