Opened 13 years ago

Closed 13 years ago

#16601 closed New feature (wontfix)

Allow setting of tabindex in presentation layer

Reported by: mike@… Owned by: nobody
Component: Template system Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I needed this for a project that I was working on, and I thought I would put the function here. I am a very new Django user and haven't so much as looked at its source code yet, but if I can get to it after my current project is finished, I'll be happy to contribute this as a proper patch if desired.

Essentially, this is a filter for use on form fields, links, etc. in order to add a tabindex attribute to it. In order to remain light, it doesn't call up an HTML parser, and so it naïvely appends tabindex="X" to the end of the list of attributes. It handles both /> and normal > tag closure, so that it works for both types of tags. If it cannot find an end-of-tag, it returns the input unaltered. Furthermore, if the tabindex parameter is passed in as a string it will attempt conversion to an integer; if that fails, it will also return the input as-is.

Attachments (1)

django-tabindex-filter.py (747 bytes ) - added by mike@… 13 years ago.
A tabindex filter

Download all attachments as: .zip

Change History (3)

by mike@…, 13 years ago

Attachment: django-tabindex-filter.py added

A tabindex filter

comment:1 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedDesign decision needed

I think this is a good candidate for http://djangosnippets.org/

However, it looks too specialized for Django itself, so I vote -1 for adding it to Django.

Let's wait for a core developer's opinion — I'm not allowed to close a ticket as "wontfix".

comment:2 by Jacob, 13 years ago

Resolution: wontfix
Status: newclosed

I agree with aaugustin - this isn't an appropriate addition to Django. Further, this ought to be fixed by the widget rendering improvements hopefully coming in 1.4, so it'll be redundant very soon.

Thanks for the suggestion!

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