mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #21431 -- GenRel->FK list_filter regression in admin
Report, analysis and tests from stephenmcd.
This commit is contained in:
@@ -389,10 +389,8 @@ class NotRelationField(Exception):
|
||||
|
||||
|
||||
def get_model_from_relation(field):
|
||||
if isinstance(field, models.related.RelatedObject):
|
||||
return field.model
|
||||
elif getattr(field, 'rel'): # or isinstance?
|
||||
return field.rel.to
|
||||
if hasattr(field, 'get_path_info'):
|
||||
return field.get_path_info()[-1].to_opts.model
|
||||
else:
|
||||
raise NotRelationField
|
||||
|
||||
|
||||
Reference in New Issue
Block a user