HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.79k stars 192 forks source link

How to loop through python-decouple variables? #96

Closed Teut2711 closed 4 years ago

Teut2711 commented 4 years ago

.env file

####### DJANGO PARAMETERS ################
SECRET_KEY=MY_KEY
DEBUG=True
#### FILE   ## NAMES ##############
DOWNLOAD_FILE=document.pdf
HTML_FILE_PATH=mydoc.htm
EXCEL_FILE_PATH=AM2.CSV
######## USER VALIDATION ##########
USER_VALID_CHECK=mathsishard
####### COLUMNS #########
COLUMNS="NAME,AD1,AD2,AD3,AD4,AD5,HOL,ENT,JT1,JT2"
####### TAGS #####
TAG1_IN_DOC_SAVED_AS_HTML=AD1
TAG2_IN_DOC_SAVED_AS_HTML=AD2
.
.
.
TAGN_IN_DOC_SAVED_AS_HTML=JT2

Now the problem is that I have a django project where I' m taking some user data through a form, using a .html file(which is a word docx saved as .html with {{ }} django tags). Further I have a csv file(database for now). In the TAGS section(plz see above) I will tell the user to put all the names of the {{ }} which he has put in the .docx file. Now my job becomes to just read the .html file and substitute all template tags with the variables by using django's render_to_string. Problems: First: How to loop over all tags underneath TAGS section like a dict?

Second: If that's not possible how to make 2 .env files(with different names obviously)?

Please help, I'm stuck badly.