Commits

Simon Meers committed bfa4cc5

add batch_update_fields validation

Comments (0)

Files changed (1)

generic/admin/mixins.py

     def get_actions(self, request):
         actions = super(BatchUpdateAdmin, self).get_actions(request)
         if self.batch_update_fields:
+            self._validate_batch_update_fields()
             if not 'batch_update' in actions:
                 actions['batch_update'] = self.get_action('batch_update')
         else:
                 del actions['batch_update']
         return actions
 
+    def _validate_batch_update_fields(self):
+        from django.db import models
+        for field in self.batch_update_fields:
+            field = self.model._meta.get_field(field)
+            if isinstance(field, models.ManyToManyField):
+                raise ImproperlyConfigured(
+                    'BatchUpdateAdmin does not yet support ManyToManyFields '
+                    ' -- coming soon.'
+                )
 
 class DelibleAdmin(admin.ModelAdmin):
     """ Admin with "undelete" functionality for Delible objects """