Skip to content

Commit e2c7c6f

Browse files
committed
Update README.md
1 parent 041f73a commit e2c7c6f

1 file changed

Lines changed: 26 additions & 18 deletions

File tree

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22

33
[![Build Status](https://travis-ci.org/theskumar/python-dotenv.svg?branch=master)](https://travis-ci.org/theskumar/python-dotenv) [![PyPI version](https://badge.fury.io/py/python-dotenv.svg)](http://badge.fury.io/py/python-dotenv) [![Downloads](https://pypip.in/download/python-dotenv/badge.svg)](https://pypi.python.org/pypi/python-dotenv/)
44

5-
Forked from awesome but simpler [django-dotenv](https://github.com/jacobian/django-dotenv). Removes black magic, makes loading .env in settings.py easier, adds remote .env file management capabilities. Works as a drop-in replacement for django-dotenv.
6-
7-
[foreman](https://github.com/ddollar/foreman) reads from `.env`. `manage.py`
8-
doesn't. Let's fix that.
9-
10-
[heroku config](https://devcenter.heroku.com/articles/config-vars) Lets you add/delete env variables on your remote server from your local command line. django-dotenv-rw when used with fabric lets you do the same ```heroku config:set DJANGO_ENV="PRODUCTION" ``` becomes ```fab config:set,DJANGO_ENV,PRODUCTION```
115

126
<!-- MarkdownTOC depth=3-->
13-
7+
- [Features](#features)
148
- [Installation](#installation)
159
- [Usage](#usage)
1610
- [Command-line interface](#command-line-interface)
@@ -20,6 +14,13 @@ doesn't. Let's fix that.
2014

2115
<!-- /MarkdownTOC -->
2216

17+
# Features
18+
19+
The original work is based on [django-dotenv](https://github.com/jacobian/django-dotenv) by jacobian.
20+
21+
- read values from .env file and loads them as environment variable.
22+
- use it any python project not just django.
23+
- commandline interface to read/write `.env` file on your local and remote servers.
2324

2425
# Installation
2526

@@ -49,23 +50,28 @@ Commands:
4950
unset Removes the given key.
5051
</pre>
5152

52-
## Loading settings from a `.env` file into your django environment
53+
## Loading variables from a `.env` file into your python project
54+
55+
### Any Python Project
5356

54-
Option 1 (suggested): Near the top of `settings.py`. Add:
57+
Add the following line at the start of the file, from your program starts:
5558

5659
```python
57-
import os
5860
import dotenv
59-
PROJECT_PATH = os.path.dirname(os.path.dirname(__file__))
60-
dotenv.load_dotenv(os.path.join(PROJECT_PATH, ".env"))
61+
DOTENV_PATH = '/path/to/.env`
62+
dotenv.load_dotenv(DOTENV_PATH)
6163
```
6264

63-
Option 2: If you want your server to set the env variables and only use `dotenv` when you're using `manage.py`: in `manage.py` add:
65+
### Django
66+
67+
If you are using django you should add the above loader script at the top of `settings.py` and `manage.py`.
68+
69+
NOTE: If you use [django-configurations], support for reading `.env` file is coming soon[1]!
70+
71+
[1] https://github.com/jezdez/django-configurations/commit/01e3f5837f3d0fed215d
72+
73+
[django-configurations]: https://github.com/jezdez/django-configurations
6474

65-
```python
66-
import dotenv
67-
dotenv.load_dotenv(os.path.join(os.path.dirname(__file__), ".env"))
68-
```
6975

7076
## Setting remote config
7177

@@ -147,4 +153,6 @@ That's it. example.com, or whoever your non-paas host is, is now 1 facor closer
147153

148154
# Contributing
149155

150-
You can either open an issue or send a pull request.
156+
Please open [an issue] or send us a pull request.
157+
158+
[an issue]: https://github.com/theskumar/python-dotenv/issues/new

0 commit comments

Comments
 (0)