I have a Django application that looks something like this:
class Server(models.Model):
hostname = models.CharField(max_length=100)
admin_credentials = models.TextField()
def get_admin_credentials(self):
return decrypt(self.admin_credentials)
Since the Django template language allows templates to call methods (which do not require arguments) from their context variables, it seems too easy for a template to skip these credentials simply by specifying the following code:
{{ server.get_admin_credentials }}
How can I prevent templates from using the method directly get_admin_credentials()?
source
share