About Secure Model Methods

For model methods that modify data, set attribute alters_data = True, so that the method can't be called from a template:

1
2
3
4
def enable(self):
    self.is_enabled = True
    self.save()
enable.alters_data = True

Tips and Tricks Programming Security Django 4.2 Django 3.2 Django 2.2