X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ae34def10b226251f0d752634a7de4f1a6b8775d..849b853b9daf946df00558e72dd90ab3822b2b1b:/apps/sponsors/fields.py diff --git a/apps/sponsors/fields.py b/apps/sponsors/fields.py index b3fa36124..ba980816f 100644 --- a/apps/sponsors/fields.py +++ b/apps/sponsors/fields.py @@ -32,7 +32,7 @@ def loads(str): class JSONFormField(forms.CharField): widget = forms.Textarea - + def clean(self, value): try: loads(value) @@ -47,7 +47,7 @@ class JSONField(models.TextField): defaults.update(kwargs) return super(JSONField, self).formfield(**defaults) - def db_type(self): + def db_type(self, connection): return 'text' def get_internal_type(self): @@ -55,7 +55,7 @@ class JSONField(models.TextField): def contribute_to_class(self, cls, name): super(JSONField, self).contribute_to_class(cls, name) - + def get_value(model_instance): return loads(getattr(model_instance, self.attname, None)) setattr(cls, 'get_%s_value' % self.name, get_value)