Updates to gilbert. Reorganizing imports and removing support for python < 2.5.4.
[philo.git] / contrib / gilbert / plugins / models.py
index b765482..0ba310e 100644 (file)
@@ -1,15 +1,15 @@
-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')
@@ -215,10 +215,10 @@ class ModelAdmin(Plugin):
                
                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):