File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -451,6 +451,13 @@ def _get_column(cls, name):
451451 """
452452 return cls ._columns [name ]
453453
454+ @classmethod
455+ def _get_column_by_db_name (cls , name ):
456+ """
457+ Returns the column, mapped by db_field name
458+ """
459+ return cls ._columns .get (cls ._db_map .get (name , name ))
460+
454461 def __eq__ (self , other ):
455462 if self .__class__ != other .__class__ :
456463 return False
Original file line number Diff line number Diff line change @@ -841,7 +841,7 @@ class ModelQuerySet(AbstractQuerySet):
841841 def _validate_select_where (self ):
842842 """ Checks that a filterset will not create invalid select statement """
843843 # check that there's either a =, a IN or a CONTAINS (collection) relationship with a primary key or indexed field
844- equal_ops = [self .model ._columns . get (w .field ) for w in self ._where if isinstance (w .operator , EqualsOperator )]
844+ equal_ops = [self .model ._get_column_by_db_name (w .field ) for w in self ._where if isinstance (w .operator , EqualsOperator )]
845845 token_comparison = any ([w for w in self ._where if isinstance (w .value , Token )])
846846 if not any ([w .primary_key or w .index for w in equal_ops ]) and not token_comparison and not self ._allow_filtering :
847847 raise QueryException (('Where clauses require either =, a IN or a CONTAINS (collection) '
You can’t perform that action at this time.
0 commit comments