1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #30409 -- Allowed using foreign key's attnames in unique/index_together and Index's fields.

This commit is contained in:
zeyneloz
2019-04-30 12:00:34 +02:00
committed by Mariusz Felisiak
parent 2106b983c4
commit 6485a5f450
3 changed files with 45 additions and 3 deletions

View File

@@ -1571,9 +1571,11 @@ class Model(metaclass=ModelBase):
# In order to avoid hitting the relation tree prematurely, we use our
# own fields_map instead of using get_field()
forward_fields_map = {
field.name: field for field in cls._meta._get_fields(reverse=False)
}
forward_fields_map = {}
for field in cls._meta._get_fields(reverse=False):
forward_fields_map[field.name] = field
if hasattr(field, 'attname'):
forward_fields_map[field.attname] = field
errors = []
for field_name in fields: