Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21306 closed Cleanup/optimization (fixed)

Fix (or document) lower-casing behavior of title filter

Reported by: Tim Graham Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: bmispelon@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The following seems unexpected to me, although there may be use cases where it's expected behavior (e.g. if you have all capitalized text and want it titled). See also #21299.

>>> from django.template.defaultfilters import title
>>> title("ABC News")
u'Abc News'

Change History (4)

comment:1 by Baptiste Mispelon, 11 years ago

Cc: bmispelon@… added
Component: UncategorizedTemplate system
Easy pickings: set
Triage Stage: UnreviewedAccepted

That behavior is consistent with python's str.title method [1].

Django's title function has two features on top of str.title:

  • title("isn't it") == "Isn't It" (whereas "isn't it".title() == "Isn'T It)
  • title("8foo") == "8foo" (whereas "8foo".title() == "8Foo")

I don't think we can fix this particular issue without breaking backwards-compatibility so I think documenting it is the best course of action.

[1] http://docs.python.org/2/library/stdtypes.html?highlight=str.title#str.title

comment:2 by Tim Graham, 11 years ago

Component: Template systemDocumentation
Type: UncategorizedCleanup/optimization
Version: 1.4master

comment:3 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In eafe279120e7e6ebe7b6d42443366088ba1a50c8:

Fixed #21306 -- Documented lower-casing behavior of title filter.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In d774cb219c4581461bd2310450605916dd7c13e6:

[1.6.x] Fixed #21306 -- Documented lower-casing behavior of title filter.

Backport of eafe279120 from master

Note: See TracTickets for help on using tickets.
Back to Top