Opened 10 years ago

Closed 10 years ago

#22703 closed New feature (wontfix)

it should be possible to access the class from the template

Reported by: sabinemaennel Owned by: nobody
Component: Uncategorized Version: 1.6
Severity: Normal Keywords: template language
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I just noticed that it is not easily possible to get the class of an iterable object in the template, since class is rejected there as for having underscores in front of it. I ended up adding a method to the model class, but I think it would be very useful to be able to ask for the class in the template, when you iterate over a list of objects with different classes.

Change History (1)

comment:1 by Tim Graham, 10 years ago

Resolution: wontfix
Status: newclosed

You should avoid complex business logic in templates. If you really to access obj.__class__, a template tag or a model method as you've done is the way to go.

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