summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2010-01-27 23:52:15 +0000
committerJustin Bronn <jbronn@gmail.com>2010-01-27 23:52:15 +0000
commit0c9f63f626952bce599fd347801b9d36b966ed07 (patch)
tree1a25ef93b668fb2a93ca8da1b7c93bc876e4990e
parent19353d9c590134a3c99d9723c1de754fe6e09626 (diff)
[1.1.X] Fixed #11969 -- `Field.post_create_sql` hook should not be called for unmanaged models. Thanks, jtiai for report.
Backport of r12313 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12314 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/sql.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
index 14fd3f8214..fcc30b2005 100644
--- a/django/core/management/sql.py
+++ b/django/core/management/sql.py
@@ -165,12 +165,12 @@ def custom_sql_for_model(model, style):
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.