There are many places that expressions can extend to, and I think indexes would make a really good candidate. There are a few things that need to happen to make this work though.
- create meta.indexes to store { index_name: IndexType('field') }
- internally translate any db_index=True to the appropriate key: val in above meta.indexes
- internally translate index_together into meta.indexes
- use compiler to generate the sql
- ensure that migrations handle these new indexes properly
I would also suggest that index names be queried to ensure we're not trying to use existing names. Not sure if migrations already do this, but I seem to remember something about not being able to track index names. Am I totally off base?
This idea would actually make a really good GSoC (or similar..) project. Is there much interest from the community in custom indexes?