mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
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: http://code.djangoproject.com/svn/django/branches/gis@7513 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
57c700d550
commit
579c9d4567
@ -436,9 +436,12 @@ def custom_sql_for_model(model, style):
|
|||||||
output = []
|
output = []
|
||||||
|
|
||||||
# Post-creation SQL should come before any initial SQL data is loaded.
|
# Post-creation SQL should come before any initial SQL data is loaded.
|
||||||
for f in opts.fields:
|
# However, this should not be done for fields that are part of a
|
||||||
if hasattr(f, '_post_create_sql'):
|
# a parent model (via model inheritance).
|
||||||
output.extend(f._post_create_sql(style, model._meta.db_table))
|
nm = opts.init_name_map()
|
||||||
|
post_sql_fields = [f for f in opts.fields if nm[f.name][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,
|
# Some backends can't execute more than one SQL statement at a time,
|
||||||
# so split into separate statements.
|
# so split into separate statements.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user