Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 57c700d commit 579c9d45679dd8f6e9d83cfd75d09fae0595dedf @jbronn jbronn committed May 2, 2008
Showing with 6 additions and 3 deletions.
  1. +6 −3 django/core/management/
@@ -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[][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.

0 comments on commit 579c9d4

Please sign in to comment.