mirror of
https://github.com/jazzband/django-constance.git
synced 2026-05-13 10:03:13 +00:00
Raise an exception if an unsupported config type is used.
This is in response to #54 and #66.
This commit is contained in:
parent
212dd67d18
commit
ee0980a99f
1 changed files with 8 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ from django import forms
|
|||
from django.contrib import admin, messages
|
||||
from django.contrib.admin import widgets
|
||||
from django.contrib.admin.options import csrf_protect_m
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.exceptions import PermissionDenied, ImproperlyConfigured
|
||||
from django.forms import fields
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
|
|
@ -57,7 +57,13 @@ class ConstanceForm(forms.Form):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(ConstanceForm, self).__init__(*args, **kwargs)
|
||||
for name, (default, help_text) in settings.CONFIG.items():
|
||||
field_class, kwargs = FIELDS[type(default)]
|
||||
config_type = type(default)
|
||||
if config_type not in FIELDS:
|
||||
raise ImproperlyConfigured("Constance doesn't support "
|
||||
"config values of the type %s. "
|
||||
"Please fix the value of '%s'."
|
||||
% (config_type, name))
|
||||
field_class, kwargs = FIELDS[config_type]
|
||||
self.fields[name] = field_class(label=name, **kwargs)
|
||||
|
||||
def save(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue