Commits

Kevin Wetzels committed cfe20cb

Support max_value for older Django versions

Comments (0)

Files changed (2)

 
 setup(
     name='django-stdfields',
-    version='1.0.1',
+    version='1.0.2',
     author=u'Kevin Wetzels',
     author_email=u'kevin@roam.be',
     url='https://bitbucket.org/roam/django-stdfields',

stdfields/forms.py

             error_messages['max_value'] = msg
         kwargs['error_messages'] = error_messages
         super(MinutesField, self).__init__(*args, **kwargs)
+        if not hasattr(self, 'max_value'):
+            # Make this work when Django does not support max_value yet
+            self.max_value = None
+            if 'max_value' in kwargs:
+                self.max_value = kwargs.pop('max_value')
         
     def _validate_max_value(self, total):
         if self.max_value and total > self.max_value: