This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#After looking for a way to check if a model instance can be deleted in django , | |
#i came across many sample, but was not working as expected. Hope this solution can help. | |
#Let start by creating an Abstract model class which can be inherited by other model | |
class ModelIsDeletable(models.Model): | |
name = models.CharField(max_length=200, blank=True, null=True, unique=True) | |
description = models.CharField(max_length=200, blank=True, null=True) | |
date_modified = models.DateTimeField(auto_now_add=True) | |