Adam Morgan
Adam Morgan

Reputation: 495

How do I add a multiline variable in a honcho .env file?

I am trying to add a multiline value for an env var in .env so that my process, run by honcho, will have access to it.

Bash uses a '\' to permit multilines. But this gives errors in honcho/python code. How to do this?

Upvotes: 4

Views: 4895

Answers (2)

phuongtm
phuongtm

Reputation: 439

Following this documentation solved my case

I was adding value of .p8 file into a var in .env file, the file's format looked like:

-----BEGIN PRIVATE KEY-----
line1
line2
line3
line4
-----END PRIVATE KEY-----

Adding \\n at where you want to enter to a new line:

KEY='-----BEGIN PRIVATE KEY-----\\nline1\\nline2\\nline3\\nline4\\n-----END PRIVATE KEY-----'

And in settings.py:

KEY = env.str('KEY', multiline=True)

check variable value by:

print(settings.KEY)

Upvotes: 5

Adam Morgan
Adam Morgan

Reputation: 495

I put '\\' at the end of the line to permit multiline values.

Upvotes: 1

Related Questions