Django

Code

Ticket #4793 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

template documentation has wrong example

Reported by: Can Burak Cilingir <canburak@cs.bilgi.edu.tr> Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

following code causes "module has no stringfilter" error

from django import template

@template.stringfilter
def lower(value):
    return value.lower()

you also need to register that filter (stringfilter is not registering it). correct example would be:

from django import template

@register.filter(name="endswith")
@template.defaultfilters.stringfilter
def endswith(value,arg):
    return value.endswith(arg)

Attachments

4793.patch (2.0 kB) - added by SmileyChris on 07/30/07 17:25:36.

Change History

07/30/07 17:21:31 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

Example is here: http://www.djangoproject.com/documentation/templates_python/#template-filters-which-expect-strings

The example just shows the code which needs to be added for the specific case, not a full working example of a template.

...although perhaps the "registering a filter" bit could have a heading of it's own and it could go below "template filters which expect strings" to clarify things.

07/30/07 17:25:36 changed by SmileyChris

  • attachment 4793.patch added.

07/30/07 17:26:35 changed by SmileyChris

  • has_patch set to 1.
  • stage changed from Accepted to Ready for checkin.

09/13/07 18:30:26 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6143]) Fixed #4793 -- Tweaked custom filter documentation a little to possibly reduce some confusion. Thanks, SmileyChris?.


Add/Change #4793 (template documentation has wrong example)




Change Properties
Action