mirror of
https://github.com/django/django.git
synced 2025-10-05 00:00:37 +00:00
Fixed #13987 -- Ensure that the primary key is set correctly for all models that have concrete-abstract-concrete inheritance, not just the first model. Thanks to Aramgutang for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15498 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9ae2a94776
commit
492b8a0821
3 changed files with 45 additions and 2 deletions
|
@ -123,6 +123,12 @@ class Options(object):
|
|||
# Promote the first parent link in lieu of adding yet another
|
||||
# field.
|
||||
field = self.parents.value_for_index(0)
|
||||
# Look for a local field with the same name as the
|
||||
# first parent link. If a local field has already been
|
||||
# created, use it instead of promoting the parent
|
||||
already_created = [fld for fld in self.local_fields if fld.name == field.name]
|
||||
if already_created:
|
||||
field = already_created[0]
|
||||
field.primary_key = True
|
||||
self.setup_pk(field)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue