Ticket #2260: fix_tables_created_in_wrong_order.diff

File fix_tables_created_in_wrong_order.diff, 1.1 KB (added by marcink@…, 9 years ago)
  • django/core/management.py

     
    9494            "Edit your settings file and change DATABASE_ENGINE to something like 'postgresql' or 'mysql'.\n"))
    9595        sys.exit(1)
    9696
     97    app_models = models.get_models(app)
     98
    9799    # Get installed models, so we generate REFERENCES right
     100    # Remove all tables belonging to app from the list of known
     101    # models, thus assuming they will be dropped before executing
     102    # CREATE commands (most common case: the sqlreset command).
    98103    final_output = []
    99     known_models = set(_get_installed_models(_get_table_list()))
     104    known_models = set([model for model in _get_installed_models(_get_table_list())
     105                        if model not in app_models])
    100106    pending_references = {}
    101107
    102     app_models = models.get_models(app)
    103 
    104108    for model in app_models:
    105109        output, references = _get_sql_model_create(model, known_models)
    106110        final_output.extend(output)
Back to Top