Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-appconf

How to install django-appconf

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-appconf
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.5
0.6Never BuiltWhy not?
0.5 Available View build log
0.4.1 Available View build log
0.4 Available View build log
0.3 Available View build log
0.2.2 Available View build log
Windows (64-bit)
0.5
0.6Never BuiltWhy not?
0.5 Available View build log
0.4.1 Available View build log
0.4 Available View build log
0.3 Available View build log
0.2.2 Available View build log
Mac OS X (10.5+)
0.5
0.6Never BuiltWhy not?
0.5 Available View build log
0.4.1 Available View build log
0.4 Available View build log
0.3 Available View build log
0.2.2 Available View build log
Linux (32-bit)
0.5
0.6Never BuiltWhy not?
0.5 Available View build log
0.4.1 Available View build log
0.4 Available View build log
0.3 Available View build log
0.2.2 Available View build log
Linux (64-bit)
0.6 Available View build log
0.5 Available View build log
0.4.1 Available View build log
0.4 Available View build log
0.3 Available View build log
0.2.2 Available View build log
0.6 Available View build log
 
Author
License
BSD
Dependencies
Lastest release
version 0.6 on Sep 20th, 2013
Build Status

A helper class for handling configuration defaults of packaged Django apps gracefully.

Overview

Say you have an app called myapp with a few defaults, which you want to refer to in the app's code without repeating yourself all the time. appconf provides a simple class to implement those defaults. Simply add something like the following code somewhere in your app files:

from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

Note

AppConf classes depend on being imported during startup of the Django process. Even though there are multiple modules loaded automatically, only the models modules (usually the models.py file of your app) are guaranteed to be loaded at startup. Therefore it's recommended to put your AppConf subclass(es) there, too.

The settings are initialized with the capitalized app label of where the setting is located at. E.g. if your models.py with the AppConf class is in the myapp package, the prefix of the settings will be MYAPP.

You can override the default prefix by specifying a prefix attribute of an inner Meta class:

from appconf import AppConf

class AcmeAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

    class Meta:
        prefix = 'acme'

The MyAppConf class will automatically look at Django's global settings to determine if you've overridden it. For example, adding this to your site's settings.py would override SETTING_1 of the above MyAppConf:

ACME_SETTING_1 = "uno"

In case you want to use a different settings object instead of the default 'django.conf.settings', set the holder attribute of the inner Meta class to a dotted import path:

from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

    class Meta:
        prefix = 'acme'
        holder = 'acme.conf.settings'

If you ship an AppConf class with your reusable Django app, it's recommended to put it in a conf.py file of your app package and import django.conf.settings in it, too:

from django.conf import settings
from appconf import AppConf

class MyAppConf(AppConf):
    SETTING_1 = "one"
    SETTING_2 = (
        "two",
    )

In the other files of your app you can easily make sure the settings are correctly loaded if you import Django's settings object from that module, e.g. in your app's views.py:

from django.http import HttpResponse
from myapp.conf import settings

def index(request):
    text = 'Setting 1 is: %s' % settings.MYAPP_SETTING_1
    return HttpResponse(text)

Subscribe to package updates

Last updated Sep 20th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.