79240674

Date: 2024-11-30 23:50:45
Score: 0.5
Natty:
Report link

Create a property in your model. It will be incapsulated in your model and more SOLID.

class Person(models.Model):
    name = models.CharField(max_length=30)

    @property
    def name_trimmed(self):
        return self.first_name.replace('&', 'and')

Then in your template:

{{ person.name_trimmed }}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Vit Amin