diff options
| author | Justin Bronn <jbronn@gmail.com> | 2008-05-02 18:38:06 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2008-05-02 18:38:06 +0000 |
| commit | 579c9d45679dd8f6e9d83cfd75d09fae0595dedf (patch) | |
| tree | 6c29536f69740f5da1a1bf137adcce6d415b4c93 | |
| parent | 57c700d550343a00494d288e4582ccaaa6b0964e (diff) | |
gis: Fixed `_post_create_sql` hook to not generate additional SQL for fields belonging to a parent model via model inheritance. Thanks, robotika.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7513 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/sql.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 42119915af..dcfe60e95b 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -436,9 +436,12 @@ def custom_sql_for_model(model, style): output = [] # Post-creation SQL should come before any initial SQL data is loaded. - for f in opts.fields: - if hasattr(f, '_post_create_sql'): - output.extend(f._post_create_sql(style, model._meta.db_table)) + # However, this should not be done for fields that are part of a + # a parent model (via model inheritance). + nm = opts.init_name_map() + post_sql_fields = [f for f in opts.fields if nm[f.name][1] is None and hasattr(f, '_post_create_sql')] + for f in post_sql_fields: + output.extend(f._post_create_sql(style, model._meta.db_table)) # Some backends can't execute more than one SQL statement at a time, # so split into separate statements. |
