On 15 May 2009, at 14:08 , Konstantin S wrote:
> Hello
>
> First of all sorry if this question was asked and answered many time
> before. I want to know what are the best practices you use for
> deployment django sites in production. I mean how do you separate
> setting.py into development and production part and how do use choose
> which one to use without much editing
The simplest way you'll find with a basic googling
(http://www.davidcramer.net/code/django/107/deploying-django.html
) is to remove the machine-specific settings from your `settings.py`
and at the end of the file add
try:
from local_settings import *
except ImportError:
pass
then on each machine you create a local_settings.py file *not under
version control* and you put your settings there.
The issue is that since local_settings.py is not under version
control, the local settings of your machines won't be versioned which
might make them painful to edit (not possible to edit production
settings from a dev machine), newly create (no example for a new
machine), debug, ...
The next "level" is to change `local_settings.py` from being a place
where local settings are stored to being a pointer to local settings
(http://lethain.com/entry/2008/nov/03/development-to-deployment-in-django/
): for each machine you create a `${machine}_settings.py` file which
*is* under version control, and `local_settings.py` (still not under
version control) simply contains `from ${machine}_settings import *`.
Then you can augment that by removing `local_settings.py` altogether
and having an automatic dispatch based on the machine's host name:
http://www.djangosnippets.org/snippets/600/
(note: variant using execfile instead of exec/from/import:
http://www.djangosnippets.org/snippets/677/)
.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---