0

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?

sgerbhctim
  • 3,420
  • 7
  • 38
  • 60

1 Answers1

0

If you're using cookiecutter>=1.7, you can use filter random_ascii_string like this :

{{ random_ascii_string(8) }}

More information available about random_ascii_string.

Nelson G.
  • 5,145
  • 4
  • 43
  • 54