Django

Code

Show
Ignore:
Timestamp:
08/06/07 11:50:17 (1 year ago)
Author:
danderson
Message:

schema-evolution: update from HEAD (v5821)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/django/core/management.py

    r5821 r5822  
    10651065                    extra_params.update(new_params) 
    10661066 
    1067                 # Add maxlength for all CharFields. 
     1067                # Add max_length for all CharFields. 
    10681068                if field_type == 'CharField' and row[3]: 
    1069                     extra_params['maxlength'] = row[3] 
     1069                    extra_params['max_length'] = row[3] 
    10701070 
    10711071                if field_type == 'DecimalField': 
     
    11421142            if f.name == 'id' and not f.primary_key and opts.pk.name == 'id': 
    11431143                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.maxlength in (None, 0): 
    1145                 e.add(opts, '"%s": CharFields require a "maxlength" 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) 
    11461146            if isinstance(f, models.DecimalField): 
    11471147                if f.decimal_places is None: 
     
    11681168                e.add(opts, '"%s": "db_index" should be either None, True or False.' % f.name) 
    11691169 
    1170             # Check that maxlength <= 255 if using older MySQL versions. 
     1170            # Check that max_length <= 255 if using older MySQL versions. 
    11711171            if settings.DATABASE_ENGINE == 'mysql': 
    11721172                db_version = connection.get_server_version() 
    1173                 if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.maxlength > 255: 
    1174                     e.add(opts, '"%s": %s cannot have a "maxlength" 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]]))) 
    11751175 
    11761176            # Check to see if the related field will clash with any 
     
    14071407    fields = ( 
    14081408        # "key" is a reserved word in MySQL, so use "cache_key" instead. 
    1409         models.CharField(name='cache_key', maxlength=255, unique=True, primary_key=True), 
     1409        models.CharField(name='cache_key', max_length=255, unique=True, primary_key=True), 
    14101410        models.TextField(name='value'), 
    14111411        models.DateTimeField(name='expires', db_index=True), 
     
    14551455    except ImportError: 
    14561456        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 = {} 
    14571461        try: # Try activating rlcompleter, because it's handy. 
    14581462            import readline 
     
    14631467            # we already know 'readline' was imported successfully. 
    14641468            import rlcompleter 
     1469            readline.set_completer(rlcompleter.Completer(imported_objects).complete) 
    14651470            readline.parse_and_bind("tab:complete") 
    1466         code.interact(
     1471        code.interact(local=imported_objects
    14671472run_shell.args = '[--plain]' 
    14681473 
     
    15791584                                (format, fixture_name, humanize(fixture_dir)) 
    15801585                        try: 
    1581                             objects = serializers.deserialize(format, fixture) 
     1586                            objects = serializers.deserialize(format, fixture) 
    15821587                            for obj in objects: 
    15831588                                count[0] += 1