Filter; Capitalise Sentences (capsentence)

1
2
3
4
5
6
7
8
9
from django import template

register = template.Library()

@register.filter
#capitalise the first letter of each sentence in a string
def capsentence(value):
    value = value.lower()
    return ". ".join([sentence.capitalize() for sentence in value.split(". ")])

More like this

  1. Name Capitalize Filter by hotani 4 years, 9 months ago
  2. Add validation for 'unique' and 'unique_together' constraints to newforms created dynamically via form_for_model or form_for_instance by mp 4 years, 8 months ago
  3. Username genrator by gustavo80br 3 years, 9 months ago
  4. Template tag to sort a list of links by pytechd 4 years, 5 months ago
  5. PseudoFieldManager by yeago 2 years, 10 months ago

Comments

(Forgotten your password?)