Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed managing foreignkey in different backend engine

  • Loading branch information...
commit edcdc1d9364224fcbc3b810b9d9fa19a10cd537c 1 parent 62baf86
authored May 11, 2010
6  README
@@ -10,6 +10,12 @@ Future backends to support are:
10 10
 - ...
11 11
 
12 12
 
  13
+IMPORTANT COMMITS:
  14
+------------------
  15
+
  16
+- http://github.com/aparo/django/commit/62baf86ff872b3a271619a4327d7b08180c89337 allows to redefin the king of autofield in DatabaseOperations of an engine
  17
+
  18
+
13 19
 
14 20
 All documentation is in the "docs" directory and online at
15 21
 http://docs.djangoproject.com/en/dev/. If you're just getting started, here's
2  django/__init__.py
... ...
@@ -1,5 +1,7 @@
1 1
 VERSION = (1, 2, 0, 'rc', 1)
2 2
 
  3
+MODIFIED = True
  4
+
3 5
 def get_version():
4 6
     version = '%s.%s' % (VERSION[0], VERSION[1])
5 7
     if VERSION[2]:
9  django/db/models/fields/related.py
@@ -851,8 +851,13 @@ def get_db_prep_save(self, value, connection):
28  django/forms/fields.py
@@ -195,9 +195,13 @@ def to_python(self, value):
195 195
         return smart_unicode(value)
196 196
 
197 197
     def widget_attrs(self, widget):
  198
+        attrs = {}
198 199
         if self.max_length is not None and isinstance(widget, (TextInput, PasswordInput)):
199 200
             # The HTML attribute is maxlength, not max_length.
200  
-            return {'maxlength': str(self.max_length)}
  201
+            attrs['maxlength'] = str(self.max_length)
  202
+        if self.required and  isinstance(widget, (TextInput, PasswordInput)):
  203
+            attrs['required'] = "required"
  204
+        return attrs
201 205
 
202 206
 class IntegerField(Field):
203 207
     default_error_messages = {
@@ -207,8 +211,9 @@ class IntegerField(Field):
207 211
     }
208 212
 
209 213
     def __init__(self, max_value=None, min_value=None, *args, **kwargs):
  214
+        self.max_value = max_value
  215
+        self.min_value = min_value
210 216
         super(IntegerField, self).__init__(*args, **kwargs)
211  
-
212 217
         if max_value is not None:
213 218
             self.validators.append(validators.MaxValueValidator(max_value))
214 219
         if min_value is not None:
@@ -230,6 +235,16 @@ def to_python(self, value):
230 235
             raise ValidationError(self.error_messages['invalid'])
231 236
         return value
232 237
 
  238
+    def widget_attrs(self, widget):
  239
+        attrs = {} 
  240
+        if self.max_value is not None and isinstance(widget, TextInput):
  241
+            attrs['max'] = str(self.max_value)
  242
+        if self.min_value is not None and isinstance(widget, TextInput):
  243
+            attrs['min'] = str(self.min_value)
  244
+        if self.required and  isinstance(widget, (TextInput, PasswordInput)):
  245
+            attrs['required'] = "required"
  246
+        return attrs
  247
+
233 248
 class FloatField(IntegerField):
234 249
     default_error_messages = {
235 250
         'invalid': _(u'Enter a number.'),
@@ -423,6 +438,15 @@ def __init__(self, regex, max_length=None, min_length=None, error_message=None,
423 438
         self.regex = regex
424 439
         self.validators.append(validators.RegexValidator(regex=regex))
425 440
 
  441
+    def widget_attrs(self, widget):
  442
+        attrs = {}
  443
+        if self.max_length is not None and isinstance(widget, (TextInput, PasswordInput)):
  444
+            # The HTML attribute is maxlength, not max_length.
  445
+            attrs['maxlength'] = str(self.max_length)
  446
+        if self.required and  isinstance(widget, (TextInput, PasswordInput)):
  447
+            attrs['required'] = "required"
  448
+        return attrs
  449
+    
426 450
 class EmailField(CharField):
427 451
     default_error_messages = {
428 452
         'invalid': _(u'Enter a valid e-mail address.'),

0 notes on commit edcdc1d

Please sign in to comment.
Something went wrong with that request. Please try again.