mirror of
https://github.com/jazzband/dj-database-url.git
synced 2026-03-16 22:20:24 +00:00
Merge pull request #130 from ParthS007/docs-improvement
Clarify the usage example in the docs
This commit is contained in:
commit
e589ed03b5
1 changed files with 21 additions and 3 deletions
24
README.rst
24
README.rst
|
|
@ -38,20 +38,38 @@ Installation is simple::
|
|||
Usage
|
||||
-----
|
||||
|
||||
Configure your database in ``settings.py`` from ``DATABASE_URL``::
|
||||
1. If ``DATABASES`` is already defined:
|
||||
|
||||
- Configure your database in ``settings.py`` from ``DATABASE_URL``::
|
||||
|
||||
import dj_database_url
|
||||
|
||||
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
|
||||
|
||||
Provide a default::
|
||||
- Provide a default::
|
||||
|
||||
DATABASES['default'] = dj_database_url.config(default='postgres://...')
|
||||
|
||||
Parse an arbitrary Database URL::
|
||||
- Parse an arbitrary Database URL::
|
||||
|
||||
DATABASES['default'] = dj_database_url.parse('postgres://...', conn_max_age=600)
|
||||
|
||||
2. If ``DATABASES`` is not defined:
|
||||
|
||||
- Configure your database in ``settings.py`` from ``DATABASE_URL``::
|
||||
|
||||
import dj_database_url
|
||||
|
||||
DATABASES = {'default': dj_database_url.config(conn_max_age=600)}
|
||||
|
||||
- Provide a default::
|
||||
|
||||
DATABASES = {'default': dj_database_url.config(default='postgres://...')}
|
||||
|
||||
- Parse an arbitrary Database URL::
|
||||
|
||||
DATABASES = {'default': dj_database_url.parse('postgres://...', conn_max_age=600)}
|
||||
|
||||
The ``conn_max_age`` attribute is the lifetime of a database connection in seconds
|
||||
and is available in Django 1.6+. If you do not set a value, it will default to ``0``
|
||||
which is Django's historical behavior of using a new database connection on each
|
||||
|
|
|
|||
Loading…
Reference in a new issue