I am looking to generate a random 8 letter hash for a cookeicutter template. In pure Python, this would generate what I'd like:
In [3]: import random
In [3]: import string
In [4]: ''.join(random.choice(string.ascii_lowercase) for i in range(8))
Out[4]: 'jrqcwtav'
In Jinja, the closest thing I could find would be a multiline solution. I need a one-liner. Any ideas?
If you're using
cookiecutter>=1.7
, you can use filterrandom_ascii_string
like this :More information available about random_ascii_string.