django-heroku-postgresify yra Django programa, kuri suteikia automatinio Django duomenų bazės konfigūraciją Heroku.
& Nbsp; Įdiegti
Norėdami įdiegti `` Django-heroku-postgresify``, tiesiog paleisti `` PIP įdiegti Django-heroku-postgresify`` ir gausite naujausią versiją automatiškai įdiegta.
Naudojimas
Keisti savo Django `` settings.py`` failą, ir nustatyti:
`` `Python
nuo postgresify importo postgresify
DUOMENŲ BAZĖS = postgresify ()
`` `
Viskas.
Priklausomai nuo Heroku PostgreSQL duomenų bazių Jūs turite įdiegta, jūsų `` DATABASES`` konfigūracija bus automatiškai setup jas naudoti.
Pavyzdžiui, tarkime, jūs turite šiuos aplinkos kintamieji, nustatyti Heroku (galite peržiūrėti visų aplinkos kintamųjų sąrašą veikia `` heroku config``):
- `` HEROKU_POSTGRESQL_BLUE_URL``
- `` HEROKU_POSTGRESQL_RED_URL``
- `` SHARED_DATABASE_URL``
- `` DATABASE_URL``
Jūsų `` DATABASES`` nustatymas būtų:
`` `Python
DUOMENŲ BAZĖS = {
& Nbsp; & nbsp; & nbsp; "Numatytasis": {
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; # DATABASE_URL configs čia
& Nbsp; & nbsp; & nbsp; }
& Nbsp; & nbsp; & nbsp; "Bendras": {
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; # SHARED_DATABASE_URL configs čia
& Nbsp; & nbsp; & nbsp; }
& Nbsp; & nbsp; & nbsp; "BLUE": {
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; # HEROKU_POSTGRESQL_BLUE_URL configs čia
& Nbsp; & nbsp; & nbsp; }
& Nbsp; & nbsp; & nbsp; "RED": {
& Nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; # HEROKU_POSTGRESQL_RED_URL configs čia
& Nbsp; & nbsp; & nbsp; }
}
`` `
Reikalavimai :
- Python
- Django
Komentarai nerastas