File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -654,14 +654,19 @@ def get_model_features(model):
654
654
]
655
655
656
656
657
- def has_feature (model , feature ):
657
+ def has_feature (model_or_ct , feature ):
658
658
"""
659
659
Returns True if the model supports the specified feature.
660
660
"""
661
- # Resolve a ContentType to its model class
662
- if type (model ) is ContentType :
663
- model = model .model_class ()
664
- ot = ObjectType .objects .get_for_model (model )
661
+ # If an ObjectType was passed, we can use it directly
662
+ if type (model_or_ct ) is ObjectType :
663
+ ot = model_or_ct
664
+ # If a ContentType was passed, resolve its model class
665
+ elif type (model_or_ct ) is ContentType :
666
+ ot = ObjectType .objects .get_for_model (model_or_ct .model_class ())
667
+ # For anything else, look up the ObjectType
668
+ else :
669
+ ot = ObjectType .objects .get_for_model (model_or_ct )
665
670
return feature in ot .features
666
671
667
672
You can’t perform that action at this time.
0 commit comments