Ticket #14796: move_keyword_check.diff

File move_keyword_check.diff, 1.4 KB (added by mmcnickle, 7 years ago)

Move the keyword check after the relations check/modifications

  • django/core/management/commands/inspectdb.py

     
    6666                if ' ' in att_name:
    6767                    att_name = att_name.replace(' ', '_')
    6868                    comment_notes.append('Field renamed to remove spaces.')
     69                   
    6970                if '-' in att_name:
    7071                    att_name = att_name.replace('-', '_')
    7172                    comment_notes.append('Field renamed to remove dashes.')
    72                 if keyword.iskeyword(att_name):
    73                     att_name += '_field'
    74                     comment_notes.append('Field renamed because it was a Python reserved word.')
     73                   
    7574                if column_name != att_name:
    7675                    comment_notes.append('Field name made lowercase.')
    7776
     
    9796                            extra_params['unique'] = True
    9897
    9998                    field_type += '('
     99                   
     100                if keyword.iskeyword(att_name):
     101                    att_name += '_field'
     102                    comment_notes.append('Field renamed because it was a Python reserved word.')
    100103
    101104                # Don't output 'id = meta.AutoField(primary_key=True)', because
    102105                # that's assumed if it doesn't exist.
Back to Top