-import operator
-from django.forms.models import ModelForm, modelform_factory
+from django.conf import settings
+from django.contrib.admin.util import lookup_field, label_for_field, display_for_field, NestedObjects
+from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.db.models.fields.related import ManyToOneRel
from django.db.models.fields.files import FieldFile, ImageFieldFile, FileField
-from django.contrib.admin.util import lookup_field, label_for_field, display_for_field, NestedObjects
+from django.forms.models import ModelForm, modelform_factory
+from django.utils import simplejson as json
from django.utils.encoding import smart_unicode
-import staticmedia
from .base import Plugin
from ..extdirect import ext_action, ext_method
-from django.core.exceptions import PermissionDenied
-from django.utils import simplejson as json
+import operator, staticmedia
@ext_action(name='models')
form = self.form_class(request.POST, request.FILES, instance=instance)
- try:
+ if form.is_valid():
saved = form.save()
return True, None, saved.pk
- except ValueError:
+ else:
return False, form.errors
def data_serialize_object(self, obj):