Skip to content

Commit

Permalink
[1.1.X] Fixed #11969 -- Field.post_create_sql hook should not be ca…
Browse files Browse the repository at this point in the history
…lled 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
  • Loading branch information
jbronn committed Jan 27, 2010
1 parent 19353d9 commit 0c9f63f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions django/core/management/sql.py
Expand Up @@ -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.
Expand Down

0 comments on commit 0c9f63f

Please sign in to comment.