Ticket #1436: management_error_messages.diff

File management_error_messages.diff, 2.7 KB (added by Antti Kaihola, 18 years ago)

fixed app_name and removed app_label for error messages

  • django/core/management.py

     
    501501    "Executes the equivalent of 'get_sql_all' in the current database."
    502502    from django.db import connection, transaction
    503503    from cStringIO import StringIO
    504     app_name = app.__name__[app.__name__.rindex('.')+1:]
    505     app_label = app_name.split('.')[-1]
     504    app_name = app.__name__.split('.')[-2]
    506505
    507506    # First, try validating the models.
    508507    s = StringIO()
     
    519518        for sql in sql_list:
    520519            cursor.execute(sql)
    521520    except Exception, e:
    522         sys.stderr.write("""Error: %s couldn't be installed. Possible reasons:
     521        sys.stderr.write("""Error: %(app_name)s couldn't be installed. Possible reasons:
    523522  * The database isn't running or isn't configured correctly.
    524523  * At least one of the database tables already exists.
    525524  * The SQL was invalid.
    526 Hint: Look at the output of 'django-admin.py sqlall %s'. That's the SQL this command wasn't able to run.
    527 The full error: %s\n""" % \
    528             (app_name, app_label, e))
     525Hint: Look at the output of 'django-admin.py sqlall %(app_name)s'. That's the SQL this command wasn't able to run.
     526The full error: %(e)s\n""" % \
     527            locals())
    529528        transaction.rollback_unless_managed()
    530529        sys.exit(1)
    531530    transaction.commit_unless_managed()
     
    536535    "Executes the equivalent of 'get_sql_reset' in the current database."
    537536    from django.db import connection, transaction
    538537    from cStringIO import StringIO
    539     app_name = app.__name__[app.__name__.rindex('.')+1:]
    540     app_label = app_name.split('.')[-1]
     538    app_name = app.__name__.split('.')[-2]
    541539
    542540    # First, try validating the models.
    543541    s = StringIO()
     
    561559            for sql in sql_list:
    562560                cursor.execute(sql)
    563561        except Exception, e:
    564             sys.stderr.write("""Error: %s couldn't be installed. Possible reasons:
     562            sys.stderr.write("""Error: %(app_name)s couldn't be installed. Possible reasons:
    565563  * The database isn't running or isn't configured correctly.
    566564  * At least one of the database tables already exists.
    567565  * The SQL was invalid.
    568 Hint: Look at the output of 'django-admin.py sqlreset %s'. That's the SQL this command wasn't able to run.
    569 The full error: %s\n""" % \
    570                 (app_name, app_label, e))
     566Hint: Look at the output of 'django-admin.py sqlreset %(app_name)s'. That's the SQL this command wasn't able to run.
     567The full error: %(e)s\n""" % \
     568                locals())
    571569            transaction.rollback_unless_managed()
    572570            sys.exit(1)
    573571        transaction.commit_unless_managed()
Back to Top