Skip to content

Commit

Permalink
Improved docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez committed Jan 6, 2015
1 parent 8a34b53 commit 14dd728
Showing 1 changed file with 49 additions and 24 deletions.
73 changes: 49 additions & 24 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ from a script outside of your usual Django code, you can use the
equivalent of Django's :func:`~django.core.management.call_command` function
with django-configurations, too.

Simply import it from ``configurations.management`` instead::
Simply import it from ``configurations.management`` instead:

.. code-block:: python
:emphasize-lines: 1
from configurations.management import call_command
Expand All @@ -30,7 +33,9 @@ Imagine for example you want to set a few environment variables, all you
have to do is to create a directory with files that have capitalized names
and contain the values you want to set.

Example::
Example:

.. code-block:: console
$ tree mysite_env/
mysite_env/
Expand All @@ -46,7 +51,9 @@ Example::
$
Then, to enable the ``mysite_env`` environment variables, simply use the
``envdir`` command line tool as a prefix for your program, e.g.::
``envdir`` command line tool as a prefix for your program, e.g.:

.. code-block:: console
$ envdir mysite_env python manage.py runserver
Expand All @@ -67,13 +74,17 @@ using pip_ to install packages.
Django 1.5.x
^^^^^^^^^^^^

First install Django 1.5.x and django-configurations::
First install Django 1.5.x and django-configurations:

.. code-block:: console
pip install -r https://raw.github.com/jezdez/django-configurations/templates/1.5.x/requirements.txt
$ pip install -r https://raw.github.com/jezdez/django-configurations/templates/1.5.x/requirements.txt
Then create your new Django project with the provided template::
Then create your new Django project with the provided template:

django-admin.py startproject mysite -v2 --template https://github.com/jezdez/django-configurations/archive/templates/1.5.x.zip
.. code-block:: console
$ django-admin.py startproject mysite -v2 --template https://github.com/jezdez/django-configurations/archive/templates/1.5.x.zip
See the repository of the template for more information:

Expand All @@ -82,13 +93,17 @@ See the repository of the template for more information:
Django 1.6.x
^^^^^^^^^^^^

First install Django 1.6.x and django-configurations::
First install Django 1.6.x and django-configurations:

.. code-block:: console
$ pip install -r https://raw.github.com/jezdez/django-configurations/templates/1.6.x/requirements.txt
pip install -r https://raw.github.com/jezdez/django-configurations/templates/1.6.x/requirements.txt
Or Django 1.6:

Or Django 1.6::
.. code-block:: console
django-admin.py startproject mysite -v2 --template https://github.com/jezdez/django-configurations/archive/templates/1.6.x.zip
$ django-admin.py startproject mysite -v2 --template https://github.com/jezdez/django-configurations/archive/templates/1.6.x.zip
Now you have a default Django 1.5.x or 1.6.x project in the ``mysite``
directory that uses django-configurations.
Expand All @@ -106,7 +121,9 @@ Celery
^^^^^

Given Celery's way to load Django settings in worker processes you should
probably just add the following to the **beginning** of your settings module::
probably just add the following to the **beginning** of your settings module:

.. code-block:: python
from configurations import importer
importer.install()
Expand Down Expand Up @@ -161,26 +178,32 @@ enable an extension in your IPython configuration. See the IPython
documentation for how to create and `manage your IPython profile`_ correctly.

Here's a quick how-to in case you don't have a profile yet. Type in your
command line shell::
command line shell:

ipython profile create
.. code-block:: console
$ ipython profile create
Then let IPython show you where the configuration file ``ipython_config.py``
was created::
was created:

.. code-block:: console
ipython locate profile
$ ipython locate profile
That should print a directory path where you can find the
``ipython_config.py`` configuration file. Now open that file and extend the
``c.InteractiveShellApp.extensions`` configuration value. It may be commented
out from when IPython created the file or it may not exist in the file at all.
In either case make sure it's not a Python comment anymore and reads like this::
In either case make sure it's not a Python comment anymore and reads like this:

# A list of dotted module names of IPython extensions to load.
c.InteractiveShellApp.extensions = [
# .. your other extensions if available
'configurations',
]
.. code-block:: python
# A list of dotted module names of IPython extensions to load.
c.InteractiveShellApp.extensions = [
# .. your other extensions if available
'configurations',
]
That will tell IPython to load django-configurations correctly on startup.
It also works with django-extensions's shell_plus_ management command.
Expand All @@ -195,12 +218,14 @@ FastCGI
In case you use FastCGI for deploying Django (you really shouldn't) and aren't
allowed to use Django's runfcgi_ management command (that would automatically
handle the setup for your if you've followed the quickstart guide above), make
sure to use something like the following script::
sure to use something like the following script:

.. code-block:: python
#!/usr/bin/env python
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
os.environ.setdefault('DJANGO_CONFIGURATION', 'MySiteConfiguration')
Expand Down

0 comments on commit 14dd728

Please sign in to comment.