I have Django project. I need to add app to INSTALLED_APPS
or change template config using another python script. What is the best way to do that?
I have several ideas.
- Open
settings.py
as text file from Python and modify it. Seems to be wheel reinvention and opens box with many errors (escaping and so on). - Use Python modules like
ast
but it is pretty low level and more for read access (and I need to write data back). - Use some Django tools (I am not sure if such tool exists).
What is the best way to do that?
PS: Parse a .py file, read the AST, modify it, then write back the modified source code is related, but it is not Django specific and pretty old.