I want to add more spaces to __str__ method, but method cut off spaces to 1.
For example:
class Spam(models.Model):
foo = models.IntegerField()
bar = models.IntegerField()
def __str__(self):
return 'more spaces {} {}!'.format(self.foo, self.bar)
This output in Django admin:
more spaces 1 2
I want : more spaces 1 2
How do this?
Where ever your str resides:
from django.utils import safestring
def __str__(self):
string = safestring.mark_safe("more spaces {}"+" "*10+ "{}!".format(self.foo, self.bar))
return string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With