About Model Methods and their Access in Templates
For all Django model methods that change the database entries anyhow, add an attribute alters_data = True
. This ensures that the method cannot be called from a template.
For example:
def calculate(self):
# does some calculations and saves them
calculate.alters_data = True
Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.