Skip to main content

Useful for deploy server installation. Adds management command to make configs for your project. Automatically recognizes media directories in 3-party applications

Project description

  • Adds management command to make configs for your project. Now it can generate config for lighttpd, logrotate, monit and deploy scripts.

  • Automatically recognizes media directories in 3-party applications and takes them into account.



  1. Put config to your INSTALLED_APPS.

  2. Set domain names for your project

    CONFIG_SITES = ['', ]
  3. Domains for which you want redirects to your site

  4. Serving static files

    Set path to media for unusual 3-party application

        'application-name': [
            ('media-root', 'media-url', ),

    Media folders with same name as application modulde will be added automatically. For example, in tinymce module media files


    will be available at url:


Stop! Aren’t Django staticfiles do that?

Yes, they do. But django-servre-config is older than staticfiles and does same job. This feature will is deprecated and will not be supported since 0.2.x release. We recommend to use Django contrib application django.contrib.statifiles. Read below about how to do it.


  1. If you use django-server-config for serving static media, add following code to the for serve static files in debug mode. Add it BEFORE django.views.static.serve

    if settings.DEBUG:
        urlpatterns += patterns('', (r'^', include('config.urls')))

In buildout.cfg:

  1. If you are using zc.buildout, you can add to your parts make-config to make config files automaticaly:

    recipe = iw.recipe.cmd
    on_install = true
    on_update = true
    cmds = sudo rm -f bin/init.d bin/lighttpd bin/logrotate bin/monit bin/*.py
       bin/django make_config init.d > bin/init.d
       bin/django make_config lighttpd > bin/lighttpd
       bin/django make_config logrotate > bin/logrotate
       bin/django make_config monit > bin/monit
       # Enable backups with duply & duplicity (
       bin/django make_config duply_conf > bin/duply_conf
       bin/django make_config duply_pre > bin/duply_pre
       bin/django make_config duply_post > bin/duply_post
       bin/django make_config duply_exclude > bin/duply_exclude
       # Collect static automaticaly
       sudo rm -Rf static
       bin/django collectstatic -l ---noinput
       sudo chown www-data:www-data -R static
       bin/django make_config > bin/
       bin/django make_config > bin/
       bin/django make_config > bin/
       bin/django make_config > bin/
       sudo chown root:root bin/*
       sudo chmod ug=rw,o=r bin/*
       sudo chmod ug=rwx,o=rx bin/init.d bin/django bin/buildout
       echo Configs were saved to "bin/"

Without bulidout

If you are not using zc.buildlout, you can add to repository shell script with commands above, it will give same effect.

Staticfiles support

Since 0.1.1 server-config supports django.contrib.staticfiles and staticfiles apps. If one of them present in INSTALLED_APPS, config for webserver will be generated with appropriate rewrite rule.

If staticfiles is used there is no need to include config.urls in On the other hand, probably you will want to include staticfiles_urlpatterns() from staticfiles app (see: django documentation about it)

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()

Duply/Duplicity backups

Django-server-config can automatically create backups configuration files. It supports duply (duplicity) configuration scheme. Duplicity is backup system written in python and using rsync algorithm and Duply is bash configuration wrapper for Duplicity.

Backup settings

Security Note

To start using backups you should specify path to main configuration file for duply. Django-server-config expects file in *.ini format. This file can contains secret passwords, so file supposed to be located somewhere in /etc/duply/conf.ini and belongs to root (superuser).


Path to duply configuration file


Temp directory, where database backups will be located. Database dumps will be deleted from file system after each backup session. Default value: '/var/backups/postgres'

Only PostgreSQL database backups are supported!

Duply configuration file

It is quite simple to configure duply. You can create duply initial config simply from command line::

duply <profile> create

Then look at ~/.duply/<profile>/conf and follow comments.

Moreover, you can use ours config template:

DUPL_PARAMS="$DUPL_PARAMS --full-if-older-than $MAX_FULLBKP_AGE --volsize $VOLSIZE "

This template encrypts backups with GPG and uplaod to AmazonS3 bucket com.mycompany.server.

Pay attention to the TAGET option. Django-server-config will automatiocally add project_name to TARGET. E.g. rendered config will contain value:

TARGET = s3+http://**********@com.mycompany.server/<myproject>

Consider trailing slash in *.ini config, django-server-config adds only myproject without slash.


  • 0.1.0 - Initial commit

  • 0.1.1 - Staticfiles support added

  • 0.1.2 - Duply backups support

  • 0.1.3 - Emergency lighttpd config fix (staticfiles didn’t work), don’t use v0.1.1!

  • 0.1.4 - Backup config bugfixes



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

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