Commit 8f46cdec authored by Justin Bronn's avatar Justin Bronn
Browse files

Fixed #11969 -- `Field.post_create_sql` hook should not be called for...

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
parent ff6b4498
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -151,9 +151,9 @@ 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()
    # 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))