Filter that adds a period at the end of a string

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django.template.defaultfilters import stringfilter
from django.template.defaulttags import register


@stringfilter
@register.filter
def assert_period(str):
    """Makes sure a string ends with a period."""
    if str[-1].isalnum():
        return "%s." % str
    else:
        return str

More like this

  1. Sophisticated order_by sorting by mawi 6 months, 1 week ago
  2. "Zoom in" on rendered HTML that the test client returns by peterbe 4 years, 2 months ago
  3. Fuzzy Time of Day by waylan 6 years ago
  4. Create multiple related objects at once by yaniv.haber 4 years, 2 months ago
  5. CSVImport by sharkus 5 years ago

Comments

(Forgotten your password?)