I was struggling one day to organize fields in the order I want when I create tickets in Trac.
- Copy templates/ticket.html into trac/myproject/templates/ticket.html
- Insert the following code snippet to the beginning of the template:
<?python # define the order field_types = ["type", "priority", "milestone", "keywords", "cc", "component"] # Sorting function def sort_nicely(field1, field2): try: idx1 = field_types.index(field1['name']) except ValueError: idx1 = 1000 # no match, push to the end try: idx2 = field_types.index(field2['name']) except ValueError: idx2 = 1000 # no match, push to the end return cmp(idx1, idx2) fields.sort(cmp=sort_nicely) ?>
That’s it, if you have any custom fields and you want them ordered, put them into the field_types list.