Question

I'm using BabelDjango to format dates and times in templates. Babel comes with some predefined formats called "short", "long", and "full". I know you can also just pass in your custom format like "DDD mmm" etc, but I would like to create a few more named formats. This would be much easier to spread a few different standard formats throughout my app.

is this possible? can I add more to Babel, or is it best to create my own tag filters in django?

Thanks!

Was it helpful?

Solution

Unfortunately defining custom aliases for date formats is not possible (yet) in Babel. The existing format names are taken from the CLDR database so they are pretty static at the moment.

I suggest you write you a wrapper function which translates your alias to a Babel date pattern.

Btw: Which date formats do you need?

Btw2: The Babel users mailing list is a good place to ask such questions (and likely you'll get faster answers).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top