- Timestamp:
- 08/06/07 11:50:17 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/schema-evolution/django/core/management.py
r5821 r5822 1065 1065 extra_params.update(new_params) 1066 1066 1067 # Add max length for all CharFields.1067 # Add max_length for all CharFields. 1068 1068 if field_type == 'CharField' and row[3]: 1069 extra_params['max length'] = row[3]1069 extra_params['max_length'] = row[3] 1070 1070 1071 1071 if field_type == 'DecimalField': … … 1142 1142 if f.name == 'id' and not f.primary_key and opts.pk.name == 'id': 1143 1143 e.add(opts, '"%s": You can\'t use "id" as a field name, because each model automatically gets an "id" field if none of the fields have primary_key=True. You need to either remove/rename your "id" field or add primary_key=True to a field.' % f.name) 1144 if isinstance(f, models.CharField) and f.max length in (None, 0):1145 e.add(opts, '"%s": CharFields require a "max length" attribute.' % f.name)1144 if isinstance(f, models.CharField) and f.max_length in (None, 0): 1145 e.add(opts, '"%s": CharFields require a "max_length" attribute.' % f.name) 1146 1146 if isinstance(f, models.DecimalField): 1147 1147 if f.decimal_places is None: … … 1168 1168 e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name) 1169 1169 1170 # Check that max length <= 255 if using older MySQL versions.1170 # Check that max_length <= 255 if using older MySQL versions. 1171 1171 if settings.DATABASE_ENGINE == 'mysql': 1172 1172 db_version = connection.get_server_version() 1173 if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.max length > 255:1174 e.add(opts, '"%s": %s cannot have a "max length" greater than 255 when you are using a version of MySQL prior to 5.0.3 (you are using %s).' % (f.name, f.__class__.__name__, '.'.join([str(n) for n in db_version[:3]])))1173 if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.max_length > 255: 1174 e.add(opts, '"%s": %s cannot have a "max_length" greater than 255 when you are using a version of MySQL prior to 5.0.3 (you are using %s).' % (f.name, f.__class__.__name__, '.'.join([str(n) for n in db_version[:3]]))) 1175 1175 1176 1176 # Check to see if the related field will clash with any … … 1407 1407 fields = ( 1408 1408 # "key" is a reserved word in MySQL, so use "cache_key" instead. 1409 models.CharField(name='cache_key', max length=255, unique=True, primary_key=True),1409 models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True), 1410 1410 models.TextField(name='value'), 1411 1411 models.DateTimeField(name='expires', db_index=True), … … 1455 1455 except ImportError: 1456 1456 import code 1457 # Set up a dictionary to serve as the environment for the shell, so 1458 # that tab completion works on objects that are imported at runtime. 1459 # See ticket 5082. 1460 imported_objects = {} 1457 1461 try: # Try activating rlcompleter, because it's handy. 1458 1462 import readline … … 1463 1467 # we already know 'readline' was imported successfully. 1464 1468 import rlcompleter 1469 readline.set_completer(rlcompleter.Completer(imported_objects).complete) 1465 1470 readline.parse_and_bind("tab:complete") 1466 code.interact( )1471 code.interact(local=imported_objects) 1467 1472 run_shell.args = '[--plain]' 1468 1473 … … 1579 1584 (format, fixture_name, humanize(fixture_dir)) 1580 1585 try: 1581 objects = serializers.deserialize(format, fixture)1586 objects = serializers.deserialize(format, fixture) 1582 1587 for obj in objects: 1583 1588 count[0] += 1
