Overview

django-configfield

A new model and form field flexible for schema changes. Internally is stored as JSON field in database.

Installation

In your settings.py

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',

    #.....................#

    'configfield',
)

In your models.py

class MyModel(models.Model):

    .....

    config = ConfigField(verbose_name=_('Config'), null=True, blank=True)

In your forms.py

class MyForm(forms.ModelForm):

    class Meta:
        model = MyModel

    def __init__(self, *args, **kwargs):
        gadget_type = kwargs.pop('gadget_type', None)
        super(GadgetForm, self).__init__(*args, **kwargs)
        if self.instance.pk:
            config_dict = self.instance.config
        else:
            config_dict = MY_DEFAULT_CONFIG_DICT
        self.fields['config'].set_config_dict(config_dict)

Development

You can get the last bleeding edge version of django-configfield by doing a clone of its hg repository:

hg clone https://bitbucket.org/msaelices/django-configfield