1👍
✅
Around django-3.0 the BASE_DIR
setting started to use a Path
[Python-doc] instead of a simple string, and you can not append a Path
with a string. You can however use /
operator [Python-doc] to join the path with a directory or filename, so you can use:
with open(settings.BASE_DIR / 'templates/newsletters/sign_up_email.txt') as f:
# …
pass
0👍
You might want to try using os.path.join. This functions builds paths that match your operating system.
import os
path = os.path.join(settings.BASE_DIR,"/templates/newsletters/sign_up_email.txt")
with open(path) as f:
# DO STUFF
Source:stackexchange.com