-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to create an initial .env file when starting a new project #300
Comments
I should add that I'm willing to contribute and help implement this feature. |
I updated the issue to include an idea on how you would invoke writing to the file in a Django app. |
I coded up the following POC that could be integrated in to the project.
|
The previous POC code generates the following
|
@sloria, any thoughts on this? I put a lot of thought and time into this. I made another POC Pull Request into Django Base Site, if you want to look at that as well. It seems like something like this could be very helpful! |
Sorry for the delay in responding. I'd say that creating boilerplate |
@sloria, How does adding a way to generate an Any python project that you have to manually figure out where each |
environs scope is limited to parsing and validating envvars--it has no opinions on what those envvars are and what they're used for. A command for writing a boilerplate .env file is the domain of project scaffolds. |
It would be helpful if there were a way to create an initial
.env
file with comments and any defaults set. If you have a project, it would be much nicer if, in the README, you don't have to copy and paste the following into an new.env
file before starting the project, and instead, you can tell them to run a script. This also has the added benefit of not having to maintain the README with any changes to environment variables you're using in your settings.I think this could be achieved by keeping track of all the calls made when initializing the settings. For example, the Env class could start keeping track of calls if an environment variable like
WRITE_ENV_VARS
is set. It could keep track of the calls in a dictionary. Maybe something like the following.If the
WRITE_ENV_VARS
is set, it must ignore variables not set to collect all the variables in your settings. It could then use theenv_vars_used
dict to write out an.env
file. Maybe something like the following.A bonus feature would be to add the keyword arguments
initial
andhelp_text
to all the type methods. This would allow you to add help text in the comments and to set a callable for setting an initial value when creating.env
files.The following:
Could be used to write an initial
.env
like the following.With Django this could be invoked in a management command as follows:
The text was updated successfully, but these errors were encountered: