Skip to main content

Buildout recipe for Django

Project description

isotoma.recipe.django can be used to install Django. It’s a whole lot like djangorecipe except that Django is treated like a proper egg.

This recipe will make three scripts available in your bin/ directory (assuming the control-script option is not set):

bin/django

This script works in exactly the same way as the manage.py script found in any typical django project; for example, you can run “bin/django syncdb”.

bin/django-admin

This script is the equivalent of the project-independent django-admin script available when django is installed using apt or easy_install.

bin/django.wsgi

An optional script, created if the wsgi option is set to “true”. This script is designed to be called by a web server.

The entire recipe assumes that your project is an egg and any apps contained within your project do not need to be on sys.path and hence refer to each other as:

from yourproject.yourapp import models

Example

[buildout]
parts = django
versions = versions
eggs =
    foo
    django-treebeard

[django]
recipe = isotoma.recipe.django
project = foo
settings = production
wsgi = true
eggs = ${buildout:eggs}

[versions]
Django = 1.3.1

Supported Options

project

The name of your django project, be it a develop egg or a regular one. Note that isotoma.recipe.django will not create a project for you if it does not exist.

settings

The name of the settings file within your project to use, allowing you to create a settings.py containing development settings, and a production.py importing the development settings and overriding them where necessary. That way you just need to change this value from “settings” to “production”. Defaults to “settings”.

extra-paths

Any extra paths to add to sys.path that should be made available to your project egg / develop-egg.

wsgi

Defaults to false. If ‘true’, create a bin/django.wsgi script that can be added to a webserver configuration (using isotoma.recipe.apache for example - see below).

bin-on-path

This feature appends the buildout bin/ directory to os.environ[‘PATH’] so that your django project will have access to the buildout executables. For example, this might be useful if you install sphinx in your buildout build and want access to the sphinx executables from within django (as is the case in the readthedocs.org project).

environment.foo

e.g:

environment.celery = "django"

Used to make more environment variables available to your django project. Any value can be added after the “environment.”. The example above adds:

os.environ["celery"] = "django"

to the django management scripts.

control-script

The name of the main management script. Defaults to “django” so if your buildout:bin-directory = “bin” (as is the default), your management script will be located at “bin/django”, and your wsgi script at “bin/django.wsgi”.

eggs

The eggs that you’d like to make available to your django project.

extra-settings

Provide a set of extra settings to override the django settings in your project, e.g.:

extra-settings =
    DATABASES['default']['USER'] = 'username'
    DATABASES['default']['PASSWORD'] = 'password'

A settings file made up of your project settings and the extra settings is then compiled in parts, added to the sys.path, then set as the django settings environment variable in the generated control script in your bin-directory.

Bugs

This project is actively maintained, and bugs can be reported to https://github.com/isotoma/isotoma.recipe.django/issues

Example with isotoma.recipe.apache

This example shows how

can be combined to create the wsgi script and an apache configuration that can run that script. The generated apache config simply needs to be symlinked into /etc/apache2/sites-available and you’re away.

[buildout]
parts =
    django
    apache
versions = versions
eggs =
    foo
    django-treebeard

[django]
recipe = isotoma.recipe.django
project = foo
settings = production
wsgi = true
eggs = ${buildout:eggs}

[eggpaths]
recipe = isotoma.recipe.eggpaths
eggs =
    Django
    foo

[facts]
recipe = isotoma.recipe.facts

[apache]
recipe = isotoma.recipe.apache:wsgi
interface = ${facts:interface.eth0.address}
sitename = example.com
serveradmin = webmaster@example.com
daemon = True
user = ${facts:user.name}
group = ${:user}
processgroup = ${django:project}
processes = 5
threads = 10
wsgi = django.wsgi
static_aliases = /admin/media:${eggpaths:Django}/django/contrib/admin/media
                 /static:${eggpaths:foo}/foo/static
                 /media:${buildout:directory}/var/media

[versions]
Django = 1.3.1

Changes

3.1.5 (2011-12-08)

  • Added an extra-settings option to inject settings lines from our buildout configuration.

3.1.4 (2011-10-25)

  • Fix bug preventing update of django script working-set.

3.1.3 (2011-10-13)

  • Documentation release - fleshed out the README documentation.

3.1.2 (2011-10-06)

  • Buildout now cleans up the django script where necessary.

  • The recipe no longer depends upon Jinja2.

  • Added a buildout configuration and empty project to the recipe as quick dirty recipe test.

  • Environment variables can now be added to the bin/django(.*) scripts allowing, for example, the addition of os.environ[‘CELERY_LOADER’] = ‘django’.

3.1.1 (2011-09-18)

  • Capitalise Jinja2 properly in dependencies so that it can be pinned properly

  • Added new option: “bin-on-path” which, if true, will add the buildout bin-directory to os.environ[‘PATH’] in each django script.

3.1.0 (2011-09-14)

  • Eggs were never being installed due to a bug that used the working set in offline mode. Now we inherit from zc.recipe.egg.Egg which gives us a standard working_set method for correctly determining working_set.

3.0.3 (2011-09-14)

  • Fixed extra-paths bug where a blank extra-paths option would add the cwd.

  • Made the recipe PEP-8 compatible.

3.0.2 (2011-06-30)

  • Adds apps to installed apps in the settings

  • Creates a test runner that can run the created apps

  • Creates an initial setup.py for the app

  • Creates a urls.py with sensible defaults, including serving static files in debug mode

  • Creates a settings.py and production.py heirachy, to enable settings overriding

  • Can download django from a specific URL

  • Added extra-paths option to append paths to sys.path in the bin/django* scripts.

2.0.0

  • Ground up rewrite, to use the django egg, rather than downloading a tarball. This has removed the ability to use the SVN trunk

1.2.3

  • Added the server_email buildout setting. Will set SERVER_EMAIL in the settings.py, so email can be correctly sent out from the server

1.2.2

  • Added the creation of staging.py for staging environment deployments

  • The project path is now correctly added to the buildout

1.2.1

  • Documentation updated

1.0

  • Forked from djangorecipe and renamed to isotoma.recipe.django.

0.20

  • The recipe know makes the django package know to setuptools during install. This closes #397864. Thanks to Daniel Bruce and Dan Fairs for the patch.

  • Fixed #451065 which fixes a problem with the WSGI log file option.

  • Added the posibilty to configure more FCGI related settings. Thanks to Vasily Sulatskov for the patch.

0.19.2

  • The generated WSGI & FCGI scripts are now properly removed when options change (fixes #328182). Thanks to Horst Gutmann for the patch.

  • Scripts are now updated when dependencies change. This fixes #44658, thanks to Paul Carduner for the patch.

0.19.1

  • Applied fix for the change in WSGI script generation. The previous release did not work properly.

0.19

  • When running again with non-newest set the recipe will no longer update the Subversion checkout. Thanks to vinilios for the patch.

  • The WSGI and FCGI scripts are now generated using Buildout’s own system. This makes them more similar to the generated manage script with regard to the setup of paths. Thanks to Jannis Leidel for the patch.

0.18

  • Paths from eggs and extra-paths now get precedence over the default system path (fixes #370420). Thanks to Horst Gutmann for the patch.

  • The generated WSGI script now uses the python option if present. This fixes #361695.

0.17.4

  • Fixed a problem when not running in verbose mode (fixes #375151).

0.17.3

  • Removed dependency on setuptools_bzr since it does not seem to work like I expected.

0.17.2

  • Changed the download code to use urllib2. This should make it work from behind proxies (fixes #362822). Thanks to pauld for the patch.

0.17.1

  • Fixed a problem with the new WSGI logging option #348797. Thanks to Bertrand Mathieu for the patch.

  • Disable generation of the WSGI log if “wsgilog” isn’t set, thanks to Jacob Kaplan-Moss for the patch.

  • Updated buildout.cfg and .bzrignore, thanks Jacob Kaplan-Moss.

0.17

  • Added an option to specify a log file for output redirection from the WSGI script. Thanks to Guido Wesdorp for the patch.

0.16

  • Subversion aliases are now supported (something like svn+mystuff://myjunk). Thanks to Remco for the patch.

0.15.2

  • Update to move pth-files finder from the __init__ method to the install method so it runs in buildout-order, else it looks for pth files in dirs that may not yet exist. Thanks to Chris Shenton for the update to his original patch.

0.15.1

  • Update to make the previously added pth-files option better documented.

0.15

  • Added “pth-files” option to add libraries to extra-paths from site .pth files. Thanks to Chris Shenton for the patch.

0.14

  • The recipe now supports creating a FCGI script. Thanks to Jannis Leidel for the patch.

  • When downloading a Django recipe for the first time the recipe now properly reports the url it is downloading from.

0.13

  • Specifying a user name within a subversion url now works. The code that determined the revision has been updated. This fixes issue #274004. Thanks to Remco for the patch.

  • Updated the template for creating new projects. It now uses the current admin system when generating it’s urls.py file. This fixes issue #276255. Thanks to Roland for the patch.

0.12.1

  • Re-upload since CHANGES.txt was missing from the release

0.12

  • The recipe no longer executes subversion to determine whether the versions is to be downloaded using subversion. This fixes issue #271145. Thanks to Kapil Thangavelu for the patch.

  • Changed the pythonpath option to extra-paths. This makes the recipe more consistent with other recipes (see issue #270908).

0.11

  • Another go at fixing the updating problem (#250811) by making sure the update method is always called. It would not be called in the previous version since the recipe wrote a random secret (if it wasn’t specified) to the options for use with a template. Buildout saw this as a change in options and therefore always decided to un-install & install.

  • When both projectegg and wsgi=True are specified, the generated wsgi file did not have the correct settings file in it. This has been fixed with a patch from Dan Fairs.

  • The recipe now has logging. All print statements have been replaced and a few extra logging calls have been added. This makes the recipe more informative about long running tasks. Thanks erny for the patch from issue #260628.

0.10

  • The recipe no longer expects the top level directory name in a release tarball to be consistent with the version number. This fixes issue #260097. Thanks to erny for reporting this issue and suggesting a solution.

  • Revision pinns for the svn checkout now stay pinned when re-running the buildout. This fixes issue #250811. Thanks to Remco for reporting this.

  • Added an option to specify an egg to use as the project. This disables the code which creates the basic project structure. Thanks to Dan Fairs for the patch from issue #252647.

0.9.1

  • Fixed the previous release which was broken due to a missing manifest file

0.9

  • The settings option is fixed so that it supports arbitrary depth settings paths (example; conf.customer.development).

  • The version argument now excepts a full svn url as well. You can use this to get a branch or fix any url to a specific revision with the standard svn @ syntax

  • The wsgi script is no longer made executable and readable only by the user who ran buildout. This avoids problems with deployment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isotoma.recipe.django-3.1.5.tar.gz (16.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page