Monday, April 2, 2018

Re: Decoupling Postgres database credentials in django for deployment.

Hi,

You could rename your dev settings file to for example 'settings_dev.py' and only commit this file (add settings.py to .gitignore).

On your Linux Server you could create a new directory in /etc

like:

/etc/django

/etc/django/app1
/etc/django/app2
...

There you store your production 'settings.py'

In your app directory you can create a symbolic link to these files:

ln -s /etc/django/app1/settings.py /path/to/app1/app1/

You have to make sure the directory in /etc is readably by www-data or whatever user you run your webserver with:

Now you can change the settings in the /etc directory and the settings are quite secure since only root will be able to change them by default. And you now do it the Linux way by storing all settings in /etc

Since you added settings.py to .gitignore it won't get overwritten. You should make backups of your whole /etc directory anyways so your django settings also get saved.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8f3d6ebb-9db1-455e-99e3-d337490ffab5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment