I write this lines in .env file in django project to link my project to my Data base
but visual code make a problem to the file
Remove "export" from your .env file.
DB_NAME=IncomSpendsDB
DB_USER=postgres
DB_PASSWORD='0000000'
DB_HOST=localhost
https://djangocentral.com/environment-variables-in-django/
Related
I am doing a Django Project and I want to store some files (which should be accessible from the project w,r) to some github project as I don't want to store the files and the projects in the same repo.
Any suggestion of doing that?
Let's say, for example, that you want to upload all files with a .css extension to a separate project.
You need to create two files in the root folder of each project. and call them .gitignore
(Don't forget the point at first)
In the repository where you want all files except css files, write in the .gitignore file:
*.css
In the repository where you only want the css files, write in the .gitignore file:
*
!*.css
You will now push the .gitignore files, respectively, to each of the projects you created.
I want to automatically import my FLASK_APP environment variable when running the Windows cmd.
I installed the python-dotenv, then created an .env file under my project main path.
However, I kept getting errors saying " Could not locate Flask application. You did not provide the FLASK_APP environment variable."
The following is the path I have for my project
project Path
And my .env is saved under the same path "Flask Virtue Environment\env\Voting Platform\Voting_Platform"
my .env file has the following code
FLASK_APP=runserver.py
Also I ran the following command to test if dotenv is able to locate my Environment File. I think it did find the file. (see below)
dotenv test
I am confused why the flask isn't able to read my .env file
I never develop flask in windows, but you can read this document to get clue for you problem.
Happy coding.
Quick question how to get the .env conf file into the server.
I have three settings file in my project base, development, production. I think testing and staging is an overkill
It is encouraged to put .env in .gitignore file. so it won't be included in version control. in Heroku, it is easy to set the environment variable in the settings tab. what about other hosting services without such a feature? since I push to my repository and pull from the server, How I am I suppose to get the API keys stored in the .env since it will ignore it (it's in gitignore) file? should I create in the server? or is there a way it is done? Newbie question I know.
You are correct. You should put your .env file in .gitignore and create .env file on server manually - either by connecting to server (SSH) and creating file or transfer file using one of secure transfer protocols (SCP, SFTP).
When I upgraded to Laravel 5 I started using the env system where I set all my configurations inside this file at the root.
.env
DB_HOST=x.x.x.x.x
DB_USERNAME
...
This file is not part of my repo and when I deploy I set the same variables onto my system environment variables (using amazon beanstalk here) so they are accessible without the need of the .env file.
So that all works but now when I use the command line in my scripts in production these system environment variables don't seem to be accessible in the command line. They are however accessible when the PHP is served through the web server.
I found if I copy add back this .env file then it works in the command line but that's why I'm confused, I thought this system was to prevent committing sensitive information to the repo and now it seems I have to do so so that I can use my php artisan migrate and other commands in production.
Am I missing something? Is there a way to get the system environment variables available in the command line or do I have to somehow create that .env file dynamically in production?
I always thought that the .env file was just part of setting up your server. The .env file is ignored by git, so once it's setup, you can push/pull to your heart's content and it'll leave the .env file alone. That's at least how I've done it so far.
Is it possible to specify the environmental variables for Webstorm using, for example, a .env file? Where a .env file is a file of just key-value pairs like KEY=value.