<commit_before># Django-MetaSettings

Simplify the obnoxious task of configuring the same Django project in multiple environments.

***

## About

Django MetaSettings allows you to place settings specific to different environments into separate files. Based on certain environmental conditions different settings can be loaded from multiple sources.


***

## Installation

### Create the environment specific settings files

Start by creating a folder to store the settings files. Since Django MetaSettings doesn't use ``import``, so the folder doesn't need to be a package. You can call the folder anything you want, but settings is recommended for the sake of simplicity.

	mkdir settings

Create a python script for each set of environmental conditions, containing the apropriate settings. For example, development.py might enable debugging and debug_toolbar.

	"""
	development.py
	Settings for development systems.
	"""

	DEBUG = True
	TEMPLATE_DEBUG = DEBUG

	INTERNAL_IPS = ('127.0.0.1',)

	MIDDLEWARE_CLASSES += (
		'debug_toolbar.middleware.DebugToolbarMiddleware',
	)

	INSTALLED_APPS += (
		'debug_toolbar',
	)

Additionally, you may want to create a settings file for each machine the application will run on.

	"""
	glados.py
	Settings for the system identified as GLaDOS.
	"""

	DATABASE_USER = 'dbuser'
	DATABASE_PASSWORD = '<PASSWORD>'

	MEDIA_ROOT = '/var/www/test/assets'
	MEDIA_URL = '/assets/'
	ADMIN_MEDIA_PREFIX = '/assets/admin/'

	TEMPLATE_DIRS = (
		"/var/www/test/templates",
	)

### Install the module

**PIP** ``pip install django-metasettings`` or **easy_install** ``easy_install django-metasettings``

### Modify the project's __init__.py

Before anything else can happen, Django MetaSettings needs to swap out the standard settings class with a custom subclass that works the magic.

	import metasettings
	metasettings.init()

### Modify the project's settings.py

	import metasettings
	METASETTINGS_METHOD = metasettings.HOSTNAME
	METASETTINGS_DIR = 'settings'
	METASETTINGS_PATTERNS = (
		(r'hostname', ('base',),
	)
<commit_msg>Taking advantage of Redcarpet's syntax highlighting.<commit_after># Django-MetaSettings

Simplify the obnoxious task of configuring the same Django project in multiple environments.

***

## About

Django MetaSettings allows you to place settings specific to different environments into separate files. Based on certain environmental conditions different settings can be loaded from multiple sources.


***

## Installation

### Create the environment specific settings files

Start by creating a folder to store the settings files. Since Django MetaSettings doesn't use ``import``, so the folder doesn't need to be a package. You can call the folder anything you want, but settings is recommended for the sake of simplicity.

``mkdir settings``

Create a python script for each set of environmental conditions, containing the apropriate settings. For example, development.py might enable debugging and debug_toolbar.

``` python
"""
development.py
Settings for development systems.
"""

DEBUG = True
TEMPLATE_DEBUG = DEBUG

INTERNAL_IPS = ('127.0.0.1',)

MIDDLEWARE_CLASSES += (
	'debug_toolbar.middleware.DebugToolbarMiddleware',
)

INSTALLED_APPS += (
	'debug_toolbar',
)
```

Additionally, you may want to create a settings file for each machine the application will run on.

``` python
"""
glados.py
Settings for the system identified as GLaDOS.
"""

DATABASE_USER = 'dbuser'
DATABASE_PASSWORD = '<PASSWORD>'

MEDIA_ROOT = '/var/www/test/assets'
MEDIA_URL = '/assets/'
ADMIN_MEDIA_PREFIX = '/assets/admin/'

TEMPLATE_DIRS = (
	"/var/www/test/templates",
)
```

### Install the module

**PIP** ``pip install django-metasettings`` or **easy_install** ``easy_install django-metasettings``

### Modify the project's __init__.py

Before anything else can happen, Django MetaSettings needs to swap out the standard settings class with a custom subclass that works the magic.

``` python
import metasettings
metasettings.init()
```

### Modify the project's settings.py

```
import metasettings
METASETTINGS_METHOD = metasettings.HOSTNAME
METASETTINGS_DIR = 'settings'
METASETTINGS_PATTERNS = (
	(r'hostname', ('base',),
)
```
{'fraction_non_alphanumeric': 0.08932409839980893, 'fraction_numerical': 0.002866013852400287, 'mean_word_length': 4.923620933521923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '754529', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1178, 'n_words': 452}