diff options
| author | Justin Bronn <jbronn@gmail.com> | 2010-01-27 23:48:41 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2010-01-27 23:48:41 +0000 |
| commit | 8f46cdec97b5203481a56dc637a44fd0e284969d (patch) | |
| tree | 8bb35970d3c3409dbe48ef22e53d36efe792ec32 | |
| parent | ff6b44980a3359981808dce8b5bc8500c171aa0c (diff) | |
Fixed #11969 -- `Field.post_create_sql` hook should not be called for unmanaged models. Thanks, jtiai for report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12313 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/sql.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 93a76f1c18..feb932f330 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -151,12 +151,12 @@ def custom_sql_for_model(model, style, connection): output = [] # Post-creation SQL should come before any initial SQL data is loaded. - # 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.local_fields if hasattr(f, 'post_create_sql')] - for f in post_sql_fields: - output.extend(f.post_create_sql(style, model._meta.db_table)) + # However, this should not be done for models that are unmanaged or + # for fields that are part of a parent model (via model inheritance). + if opts.managed: + post_sql_fields = [f for f in opts.local_fields if 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. |
