Code

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#21306 closed Cleanup/optimization (fixed)

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

Reported by: timo Owned by: nobody
Component: Documentation Version: master
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'

Attachments (0)

Change History (4)

comment:1 Changed 6 months ago by bmispelon

  • Cc bmispelon@… added
  • Component changed from Uncategorized to Template system
  • Easy pickings set
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 6 months ago by timo

  • Component changed from Template system to Documentation
  • Type changed from Uncategorized to Cleanup/optimization
  • Version changed from 1.4 to master

comment:3 Changed 6 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In eafe279120e7e6ebe7b6d42443366088ba1a50c8:

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

comment:4 Changed 6 months ago by Tim Graham <timograham@…>

In d774cb219c4581461bd2310450605916dd7c13e6:

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

Backport of eafe279120 from master

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.