Author: jbronn Date: 2010-01-27 17:48:41 -0600 (Wed, 27 Jan 2010) New Revision: 12313
Modified: django/trunk/django/core/management/sql.py Log: Fixed #11969 -- `Field.post_create_sql` hook should not be called for unmanaged models. Thanks, jtiai for report. Modified: django/trunk/django/core/management/sql.py =================================================================== --- django/trunk/django/core/management/sql.py 2010-01-27 23:09:46 UTC (rev 12312) +++ django/trunk/django/core/management/sql.py 2010-01-27 23:48:41 UTC (rev 12313) @@ -151,12 +151,12 @@ 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. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.